Flag JS Literals and ignore assignments/accesses to invalid props, instead of adding an index (#25996)

* Remove index signatures from js literals, use an object flag to indicate errors should be ignored instead

* Add focused test on the keyof problem

* Fix fourslash test

* Reenable errors with noImplicitAny flag

* Also disable excess property checks outside of noImplicitAny mode for js literals

* Edit and move comments
This commit is contained in:
Wesley Wigham
2018-08-02 13:40:44 -07:00
committed by GitHub
parent eb763f0792
commit fefc47fae3
65 changed files with 526 additions and 369 deletions

View File

@@ -0,0 +1,14 @@
// @allowJs: true
// @outDir: ./out
// @filename: file.js
// @ts-check
const obj = {
x: 1,
y: 2
};
/**
* @type {keyof typeof obj}
*/
let selected = "x";
selected = "z"; // should fail

View File

@@ -28,7 +28,7 @@ verify.rangeIs(`
m2(c: C): any {
throw new Error("Method not implemented.");
}
y: { [x: string]: any; };
y: {};
m1(): any {
throw new Error("Method not implemented.");
}