mirror of
https://github.com/swc-project/swc.git
synced 2024-11-28 02:29:04 +03:00
21 lines
666 B
TypeScript
21 lines
666 B
TypeScript
// @strict: true
|
|
|
|
declare let optionalProperties: { k1?: string };
|
|
declare let undefinedProperties: { k1: string | undefined };
|
|
|
|
declare let stringDictionary: { [key: string]: string };
|
|
stringDictionary = optionalProperties; // ok
|
|
stringDictionary = undefinedProperties; // error
|
|
|
|
declare let probablyArray: { [key: number]: string };
|
|
declare let numberLiteralKeys: { 1?: string };
|
|
probablyArray = numberLiteralKeys; // error
|
|
|
|
declare let optionalUndefined: { k1?: undefined };
|
|
let dict: { [key: string]: string } = optionalUndefined; // error
|
|
|
|
function f<T>() {
|
|
let optional: { k1?: T } = undefined!;
|
|
let dict: { [key: string]: T | number } = optional; // ok
|
|
}
|