-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Breaking ChangeWould introduce errors in existing codeWould introduce errors in existing codeDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issueHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Description
TypeScript Version: 2.1.5 (bug is present on master)
Code
const element = document.createElement('div');
const dataset = element.dataset;
dataset['key1'] = 'Hello';
console.log(dataset['key1'].toUpperCase()); // HELLO
console.log(dataset['key2'].toUpperCase()); // Cannot read property 'toUpperCase' of undefined
Expected behavior:
The project doesn't compile with a type error.
Actual behavior:
The project does compile, and a runtime error occurs.
This is caused by the fact that DOMStringMap
's index return has type string
, and not string | undefined
.
We want
interface DOMStringMap {
[name: string]: string;
}
To be
interface DOMStringMap {
[name: string]: string | undefined;
}
If this is approved, I am very happy to make a PR on this - and would like to do so to try and contribute to TypeScript codebase.
Metadata
Metadata
Assignees
Labels
Breaking ChangeWould introduce errors in existing codeWould introduce errors in existing codeDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issueHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript