Files
tsgo/testdata/baselines/reference/submodule/compiler/checkJsObjectLiteralHasCheckedKeyof.errors.txt

18 lines
393 B
Plaintext

file.js(11,1): error TS2322: Type '"z"' is not assignable to type '"x" | "y"'.
==== file.js (1 errors) ====
// @ts-check
const obj = {
x: 1,
y: 2
};
/**
* @type {keyof typeof obj}
*/
let selected = "x";
selected = "z"; // should fail
~~~~~~~~
!!! error TS2322: Type '"z"' is not assignable to type '"x" | "y"'.