TypeScript/tests/cases/compiler/lateBoundConstraintTypeChecksCorrectly.ts
Anders Hejlsberg 5f0d88096c Update test
2018-04-18 15:43:32 -07:00

22 lines
486 B
TypeScript

// @keyofStringsOnly: true
declare const fooProp: unique symbol;
declare const barProp: unique symbol;
type BothProps = typeof fooProp | typeof barProp;
export interface Foo<T> {
[fooProp]: T;
[barProp]: string;
}
function f<T extends Foo<number>>(x: T) {
const abc = x[fooProp]; // expected: 'T[typeof fooProp]'
/**
* Expected: no error
*/
const def: T[typeof fooProp] = x[fooProp];
const def2: T[typeof barProp] = x[barProp];
}