Store reference to namespace instead of type
Say I have a namespace like so:
export namespace Foo1
export namespace Foo2
export namespace Foo3
export interface Foo4
export interface Foo5
in a .ts file I have something like this:
import Foo1 from './foo';
const bar1 = function()
type t = Foo1.Foo2.Foo3.Foo4;
const bar2 = function()
type t = Foo1.Foo2.Foo3.Foo5;
this can get kinda verbose, I am looking to do something like this instead:
import Foo1 from './foo';
type Foo3 = Foo1.Foo2.Foo3; // <<< this don't work, I get an error explained below
const bar1 = function()
type t = Foo3.Foo4;
const bar2 = function()
type t = Foo3.Foo5;
but I can't seem to store a reference to a namespace, I can only store a reference to a type? (The error I get is that namespace Foo2 has no exported member Foo3).
tsc typescript3.0
add a comment |
Say I have a namespace like so:
export namespace Foo1
export namespace Foo2
export namespace Foo3
export interface Foo4
export interface Foo5
in a .ts file I have something like this:
import Foo1 from './foo';
const bar1 = function()
type t = Foo1.Foo2.Foo3.Foo4;
const bar2 = function()
type t = Foo1.Foo2.Foo3.Foo5;
this can get kinda verbose, I am looking to do something like this instead:
import Foo1 from './foo';
type Foo3 = Foo1.Foo2.Foo3; // <<< this don't work, I get an error explained below
const bar1 = function()
type t = Foo3.Foo4;
const bar2 = function()
type t = Foo3.Foo5;
but I can't seem to store a reference to a namespace, I can only store a reference to a type? (The error I get is that namespace Foo2 has no exported member Foo3).
tsc typescript3.0
add a comment |
Say I have a namespace like so:
export namespace Foo1
export namespace Foo2
export namespace Foo3
export interface Foo4
export interface Foo5
in a .ts file I have something like this:
import Foo1 from './foo';
const bar1 = function()
type t = Foo1.Foo2.Foo3.Foo4;
const bar2 = function()
type t = Foo1.Foo2.Foo3.Foo5;
this can get kinda verbose, I am looking to do something like this instead:
import Foo1 from './foo';
type Foo3 = Foo1.Foo2.Foo3; // <<< this don't work, I get an error explained below
const bar1 = function()
type t = Foo3.Foo4;
const bar2 = function()
type t = Foo3.Foo5;
but I can't seem to store a reference to a namespace, I can only store a reference to a type? (The error I get is that namespace Foo2 has no exported member Foo3).
tsc typescript3.0
Say I have a namespace like so:
export namespace Foo1
export namespace Foo2
export namespace Foo3
export interface Foo4
export interface Foo5
in a .ts file I have something like this:
import Foo1 from './foo';
const bar1 = function()
type t = Foo1.Foo2.Foo3.Foo4;
const bar2 = function()
type t = Foo1.Foo2.Foo3.Foo5;
this can get kinda verbose, I am looking to do something like this instead:
import Foo1 from './foo';
type Foo3 = Foo1.Foo2.Foo3; // <<< this don't work, I get an error explained below
const bar1 = function()
type t = Foo3.Foo4;
const bar2 = function()
type t = Foo3.Foo5;
but I can't seem to store a reference to a namespace, I can only store a reference to a type? (The error I get is that namespace Foo2 has no exported member Foo3).
tsc typescript3.0
tsc typescript3.0
edited Nov 16 '18 at 2:36
Alexander Mills
asked Nov 16 '18 at 2:29
Alexander MillsAlexander Mills
19.9k35163346
19.9k35163346
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I tried it like this and it works
namespace Shapes
export namespace Polygons
export namespace Square
export interface Foo4
export namespace Triangle
export interface Foo5
import polygons = Shapes.Polygons;
type myType = polygons.Square.Foo4;
export class myClass implements polygons.Square.Foo4
myFoo4 = 'Foo4';
const myFooInstance = new myClass();
console.log(myFooInstance.myFoo4);

nice work, who woulda thunk! thanks!
– Alexander Mills
Nov 16 '18 at 4:18
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53330600%2fstore-reference-to-namespace-instead-of-type%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I tried it like this and it works
namespace Shapes
export namespace Polygons
export namespace Square
export interface Foo4
export namespace Triangle
export interface Foo5
import polygons = Shapes.Polygons;
type myType = polygons.Square.Foo4;
export class myClass implements polygons.Square.Foo4
myFoo4 = 'Foo4';
const myFooInstance = new myClass();
console.log(myFooInstance.myFoo4);

nice work, who woulda thunk! thanks!
– Alexander Mills
Nov 16 '18 at 4:18
add a comment |
I tried it like this and it works
namespace Shapes
export namespace Polygons
export namespace Square
export interface Foo4
export namespace Triangle
export interface Foo5
import polygons = Shapes.Polygons;
type myType = polygons.Square.Foo4;
export class myClass implements polygons.Square.Foo4
myFoo4 = 'Foo4';
const myFooInstance = new myClass();
console.log(myFooInstance.myFoo4);

nice work, who woulda thunk! thanks!
– Alexander Mills
Nov 16 '18 at 4:18
add a comment |
I tried it like this and it works
namespace Shapes
export namespace Polygons
export namespace Square
export interface Foo4
export namespace Triangle
export interface Foo5
import polygons = Shapes.Polygons;
type myType = polygons.Square.Foo4;
export class myClass implements polygons.Square.Foo4
myFoo4 = 'Foo4';
const myFooInstance = new myClass();
console.log(myFooInstance.myFoo4);

I tried it like this and it works
namespace Shapes
export namespace Polygons
export namespace Square
export interface Foo4
export namespace Triangle
export interface Foo5
import polygons = Shapes.Polygons;
type myType = polygons.Square.Foo4;
export class myClass implements polygons.Square.Foo4
myFoo4 = 'Foo4';
const myFooInstance = new myClass();
console.log(myFooInstance.myFoo4);

answered Nov 16 '18 at 4:01
Gabriel LopezGabriel Lopez
28217
28217
nice work, who woulda thunk! thanks!
– Alexander Mills
Nov 16 '18 at 4:18
add a comment |
nice work, who woulda thunk! thanks!
– Alexander Mills
Nov 16 '18 at 4:18
nice work, who woulda thunk! thanks!
– Alexander Mills
Nov 16 '18 at 4:18
nice work, who woulda thunk! thanks!
– Alexander Mills
Nov 16 '18 at 4:18
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53330600%2fstore-reference-to-namespace-instead-of-type%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown