mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
29 lines
409 B
TypeScript
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
|