You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Namespaces are objects that can hold types, but cannot be passed around because don't have a type themselves.
Objects are mostly namespaces which can be passed around because they are typed, but cannot hold types in them.
OK, so there is a value, i.e. the entity that exists at runtime in JS, there is a type, i.e. the design time construct that is defined in a TS file, and there is a namespace, something that can contain, values, types and other namespaces.
a name can have 1, 2, or all 3 meanings based on its declaration. so a class is both a type and a value. an enum, is a value, a type, and a namespace, etc..
typeof value returns the type of a value. a namespace can not have a type. just cause it does not make much sense. in the example above, T is a type, it is not a property on the value N, it is just another type that is accessed using the name N.T.
this is what i meant by askign for a proposal on how this would fit in the existing design in #8308 (comment)
I think the two issues are the more or less the same issue, and a clear and detailed proposal is needed. marking this issue as a duplicate.
practically (as far as i know it) i only pass types and values (never types alone), although it is a valid question, need to find a use case that does it
Activity
mhegazy commentedon Apr 28, 2016
so what is the proposal? and how is it different from #8308?
zpdDG4gta8XKpMCd commentedon Apr 28, 2016
proposal goes: make namespaces first class citizens, which is
they are different in a scope of work, #8308 is (hopefully) less work and because of that might win over this request
mhegazy commentedon Apr 28, 2016
i am guessing you mean define a parameter as a namespace, you can pass them now just fine.
zpdDG4gta8XKpMCd commentedon Apr 28, 2016
not sure what you mean:
mhegazy commentedon Apr 28, 2016
the value N (the object literal equivalent) does not exist. so
typeof Nis nothing.namespace N { export var x; }has a type and it is{ x: any }.mhegazy commentedon Apr 28, 2016
I still do not see much difference and/or proposals than #8308. i would rather have one issue.
zpdDG4gta8XKpMCd commentedon Apr 28, 2016
which one is more likely to be implemented this (unifying objects and namespaces) or #8308 (adding types as pseudo-properties of objects)?
can you show an example of passing a namespace as an argument?
mhegazy commentedon Apr 28, 2016
zpdDG4gta8XKpMCd commentedon Apr 28, 2016
i am talking about this
mhegazy commentedon Apr 28, 2016
OK, so there is a value, i.e. the entity that exists at runtime in JS, there is a type, i.e. the design time construct that is defined in a TS file, and there is a namespace, something that can contain, values, types and other namespaces.
a name can have 1, 2, or all 3 meanings based on its declaration. so a class is both a type and a value. an enum, is a value, a type, and a namespace, etc..
you can read more about this at: http://www.typescriptlang.org/docs/handbook/declaration-merging.html
typeof valuereturns the type of a value. a namespace can not have a type. just cause it does not make much sense. in the example above,Tis a type, it is not a property on the valueN, it is just another type that is accessed using the nameN.T.this is what i meant by askign for a proposal on how this would fit in the existing design in #8308 (comment)
I think the two issues are the more or less the same issue, and a clear and detailed proposal is needed. marking this issue as a duplicate.
zpdDG4gta8XKpMCd commentedon Apr 28, 2016
i am closing the other one (#8308) then
DanielRosenwasser commentedon Apr 28, 2016
#420 seems vaguely related for the record.
The thing is that there is no value side to non-instantiated namespaces. Something like
doesn't actually have any associated emit, so it's not clear what you'd pass in for a function like
Does
compile to the following?
zpdDG4gta8XKpMCd commentedon Apr 28, 2016
practically (as far as i know it) i only pass types and values (never types alone), although it is a valid question, need to find a use case that does it
zpdDG4gta8XKpMCd commentedon Apr 28, 2016
side note, you don't need to pass types-only namespace, you can make it on site as you want: