mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-24 20:44:53 -05:00
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:
14
tests/cases/compiler/checkJsObjectLiteralHasCheckedKeyof.ts
Normal file
14
tests/cases/compiler/checkJsObjectLiteralHasCheckedKeyof.ts
Normal 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
|
||||
@@ -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.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user