1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
//// [tests/cases/compiler/discriminateWithMissingProperty.ts] ////
=== discriminateWithMissingProperty.ts ===
type Arg = {
>Arg : { mode: "numeric"; data: number; } | { mode: "alphabetic"; data: string; } | { data: string | Uint8Array; }
mode: "numeric",
>mode : "numeric"
data: number,
>data : number
} | {
mode: "alphabetic",
>mode : "alphabetic"
data: string,
>data : string
} | {
data: string | Uint8Array;
>data : string | Uint8Array
}
declare function foo(arg: Arg): void;
>foo : (arg: Arg) => void
>arg : Arg
foo({ mode: "numeric", data: new Uint8Array([30]) }); // Should error
>foo({ mode: "numeric", data: new Uint8Array([30]) }) : void
>foo : (arg: Arg) => void
>{ mode: "numeric", data: new Uint8Array([30]) } : { mode: "numeric"; data: Uint8Array; }
>mode : "numeric"
>"numeric" : "numeric"
>data : Uint8Array
>new Uint8Array([30]) : Uint8Array
>Uint8Array : Uint8ArrayConstructor
>[30] : number[]
>30 : 30
|