Files
tsgo/testdata/baselines/reference/submodule/compiler/checkJsObjectLiteralHasCheckedKeyof.js

29 lines
409 B
TypeScript

//// [tests/cases/compiler/checkJsObjectLiteralHasCheckedKeyof.ts] ////
//// [file.js]
// @ts-check
const obj = {
x: 1,
y: 2
};
/**
* @type {keyof typeof obj}
*/
let selected = "x";
selected = "z"; // should fail
//// [file.js]
"use strict";
// @ts-check
const obj = {
x: 1,
y: 2
};
/**
* @type {keyof typeof obj}
*/
let selected = "x";
selected = "z"; // should fail