microsoft / microsoft/TypeScript
Provide a way to alias namespaces
Open
Nobody has claimed this yet.
Needs More Info
Suggestion
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript should have a way to embed (type) namespaces. In the following case, assigned (embeded) namespace NS.A should have a C type.
TypeScript Version: master
Code
namespace NS_A {
export class C {
}
}
namespace NS {
export var A = NS_A;
export type A = NS_A;
}
var C = NS.A.C;
type C = NS.A.C;
Expected behavior:
$ node built/local/tsc.js --lib es6 -m commonjs --noEmit index.ts
Actual behavior:
$ node built/local/tsc.js --lib es6 -m commonjs --noEmit index.ts
index.ts(7,19): error TS2304: Cannot find name 'NS_A'.
index.ts(10,13): error TS2305: Module 'NS' has no exported member 'A'.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproducer in index.ts and run the issue's built/local/tsc.js command to confirm the namespace and type errors. Trace the compiler's handling of namespace aliases and exported types, then define the expected behavior for both the value expression and type reference. Done means the sample compiles without the reported errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100