No error when namespace export is used before assigned
See original GitHub issueTypeScript Version: 2.6.2
Search Terms: namespace decorator same class
Code
@C1.Decorator
export class C1{ }
export namespace C1 {
export function Decorator<T>(target: T) { }
}
@C1.Decorator
@C2.Decorator
export class C2 { }
export namespace C2 {
export function Decorator<T>(target: T) { }
}
Expected behavior: if this is not a feature, decorator should be defined at runtime, or it should provide some warning or error during compilation?
Actual behavior: decorator from namespace C1 used on class C1 is undefined, decorator from C1 is defined when used on C2, decorator from C2 is undefined
Related Issues: I did not find any
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Typescript error "An export assignment cannot be used in a ...
I found that I could combine export = syntax with namespace to export types from the interface. export = is necessary (as far...
Read more >Fixing the "Cannot Use Namespace as a Type" Error in ...
To fix this error, use an export assignment to specify a default export for the namespace, like this: car.d.ts declare module 'car' {...
Read more >Documentation - Namespaces - TypeScript
This post outlines the various ways to organize your code using namespaces (previously “internal modules”) in TypeScript. As we alluded in our note...
Read more >export - JavaScript - MDN Web Docs
The export declaration is used to export values from a JavaScript module. Exported values can then be imported into other programs with the ......
Read more >Google TypeScript Style Guide
Identifiers should not generally use $ , except when aligning with naming ... Some libraries might commonly use a namespace import prefix that...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It looks like the general problem is that we don’t give you a used-before-assigned error for a variable in a namespace.
It seems like we could do this, so marking as a bug for now.
Now that functions support expando properties in TS (and have for some time in JS), the same bug repros there: