Search Terms
libdom name
Suggestion
When checking the identifier definition, if the symbol is defined in libdom.d.ts and the identifier is called name, emit a diagnostics.
Use Cases
name is a common variable in daily programming, unfortunately, there is a global variable named name in libdom.d.ts ( https://developer.mozilla.org/en-US/docs/Web/API/Window/name )
Now the global name is type never but not all cases are covered by the never type. for example:
export function x(y: string) {
if (y === name) return true
// ~~~~ implicit bug, typescript won't give a type error here
return false
}
This is a breaking change. And if someone really wants to use the global name, I'd like to suggest them to use window.name.
I'd like to implement this feature if the TypeScript team will accept it.
Checklist
My suggestion meets these guidelines:
Search Terms
libdomnameSuggestion
When checking the identifier definition, if the symbol is defined in
libdom.d.tsand the identifier is calledname, emit a diagnostics.Use Cases
nameis a common variable in daily programming, unfortunately, there is a global variable namednameinlibdom.d.ts( https://developer.mozilla.org/en-US/docs/Web/API/Window/name )Now the global
nameis type never but not all cases are covered by thenevertype. for example:This is a breaking change. And if someone really wants to use the global
name, I'd like to suggest them to usewindow.name.I'd like to implement this feature if the TypeScript team will accept it.
Checklist
My suggestion meets these guidelines: