TypeScript/tests/cases/compiler/checkJsObjectLiteralHasCheckedKeyof.ts
Wesley Wigham fefc47fae3
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
2018-08-02 13:40:44 -07:00

15 lines
209 B
TypeScript

// @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