26 lines
622 B
Text
26 lines
622 B
Text
=== tests/cases/conformance/expressions/typeGuards/TypeGuardWithArrayUnion.ts ===
|
|
class Message {
|
|
>Message : Message
|
|
|
|
value: string;
|
|
>value : string
|
|
}
|
|
|
|
function saySize(message: Message | Message[]) {
|
|
>saySize : (message: Message | Message[]) => number
|
|
>message : Message | Message[]
|
|
>Message : Message
|
|
>Message : Message
|
|
|
|
if (message instanceof Array) {
|
|
>message instanceof Array : boolean
|
|
>message : Message | Message[]
|
|
>Array : ArrayConstructor
|
|
|
|
return message.length; // Should have type Message[] here
|
|
>message.length : number
|
|
>message : Message[]
|
|
>length : number
|
|
}
|
|
}
|
|
|