-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Closed
Copy link
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Declaration EmitThe issue relates to the emission of d.ts filesThe issue relates to the emission of d.ts filesEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Help WantedYou can do thisYou can do this
Milestone
Description
TypeScript Version: 4.0.0-dev.20200522
Search Terms:
Code
function foo() {}
foo.null = true;Expected behavior:
Any syntactically valid output. Since namespaces can't hold keyword names one option is generating an object type with call signature:
declare var foo: {
(): void;
null: boolean;
}This change would also allow to generate declarations for statically-analyzable dynamic property access expressions (i.e. foo["foo bar"] = true), which are currently omitted from declarations, resulting different behavior between in-project and out-of-project values.
Actual behavior:
declare function foo(): void;
declare namespace foo {
var null: boolean;
// ^^^^^^^ TS2693: 'boolean' only refers to a type, but is being used as a value here.
// ^^^^^ TS1134: Variable declaration expected.
}Playground Link: https://www.typescriptlang.org/play?ts=4.0.0-dev.20200522#code/GYVwdgxgLglg9mABMOcAUBKRBvAvgKBTgDowQAbcxAXkSgCcQBTAbiA
Related Issues:
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Declaration EmitThe issue relates to the emission of d.ts filesThe issue relates to the emission of d.ts filesEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Help WantedYou can do thisYou can do this