microsoft / microsoft/TypeScript
`export as namespace` still allows access via properties in module files
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: 3.8.0-dev.20200119
Search Terms: export as namespace
Code
someModule.d.ts:
export function foo (bar: string): void;
export as namespace someModule;
index.ts:
import { foo } from './someModule';
someModule.foo;
window.someModule.foo;
globalThis.someModule.foo;
Expected behavior:
All of the attempts to access someModule as a global namespace in index.ts should result in compile-time errors, as index.ts is not a script file.
Actual behavior:
window.someModule.foo and globalThis.someModule.foo do NOT result in compile-time errors.
Playground Link: N/A (requires multiple files)
Related Issues: None found
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
Reproduce the issue with the two files shown, someModule.d.ts and index.ts, using the reported TypeScript version or a current build. Compare diagnostics for direct, window, and globalThis access, then trace the compiler handling of export as namespace. Done means all three global-namespace accesses in the module file produce compile-time errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100