-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
SuggestionAn idea for TypeScriptAn idea for TypeScriptToo ComplexAn issue which adding support for may be too complex for the value it addsAn issue which adding support for may be too complex for the value it adds
Description
There is a category of bugs caused by unintended coercion at runtime. Such bugs can be found by the compiler. Having an option that bans such coercion would be a great addition.
examples of the problem:
// before (typechecks)
let isFirst: boolean;
// ... later in code
if (!isFirst) {
// do stuff
}
// after refactoring (still typechecks)
let isFirst: () => boolean;
// ... later in code
if (!isFirst) {
// got a bug, unreachable code
}// before (typechecks)
let counter: number;
let kind: string;
// ... later in code
let id = '--' + kind + (counter++); // works: --blah-blah-341279
// after refactoring (still typechecks)
let counter: number;
let kind: {
type: string;
sort: string;
};
// ... later in code
let id = '--' + kind + (counter++); // now a bug: --[object Object]-341279Elephant-Vessel, Bobris and zspitz
Metadata
Metadata
Assignees
Labels
SuggestionAn idea for TypeScriptAn idea for TypeScriptToo ComplexAn issue which adding support for may be too complex for the value it addsAn issue which adding support for may be too complex for the value it adds