162 lines
3.4 KiB
Plaintext
162 lines
3.4 KiB
Plaintext
|
=== tests/cases/conformance/expressions/unaryOperators/voidOperator/voidOperatorWithStringType.ts ===
|
||
|
// void operator on string type
|
||
|
var STRING: string;
|
||
|
>STRING : string
|
||
|
|
||
|
var STRING1: string[] = ["", "abc"];
|
||
|
>STRING1 : string[]
|
||
|
>["", "abc"] : string[]
|
||
|
|
||
|
function foo(): string { return "abc"; }
|
||
|
>foo : () => string
|
||
|
|
||
|
class A {
|
||
|
>A : A
|
||
|
|
||
|
public a: string;
|
||
|
>a : string
|
||
|
|
||
|
static foo() { return ""; }
|
||
|
>foo : () => string
|
||
|
}
|
||
|
module M {
|
||
|
>M : typeof M
|
||
|
|
||
|
export var n: string;
|
||
|
>n : string
|
||
|
}
|
||
|
|
||
|
var objA = new A();
|
||
|
>objA : A
|
||
|
>new A() : A
|
||
|
>A : typeof A
|
||
|
|
||
|
// string type var
|
||
|
var ResultIsAny1 = void STRING;
|
||
|
>ResultIsAny1 : any
|
||
|
>void STRING : undefined
|
||
|
>STRING : string
|
||
|
|
||
|
var ResultIsAny2 = void STRING1;
|
||
|
>ResultIsAny2 : any
|
||
|
>void STRING1 : undefined
|
||
|
>STRING1 : string[]
|
||
|
|
||
|
// string type literal
|
||
|
var ResultIsAny3 = void "";
|
||
|
>ResultIsAny3 : any
|
||
|
>void "" : undefined
|
||
|
|
||
|
var ResultIsAny4 = void { x: "", y: "" };
|
||
|
>ResultIsAny4 : any
|
||
|
>void { x: "", y: "" } : undefined
|
||
|
>{ x: "", y: "" } : { x: string; y: string; }
|
||
|
>x : string
|
||
|
>y : string
|
||
|
|
||
|
var ResultIsAny5 = void { x: "", y: (s: string) => { return s; } };
|
||
|
>ResultIsAny5 : any
|
||
|
>void { x: "", y: (s: string) => { return s; } } : undefined
|
||
|
>{ x: "", y: (s: string) => { return s; } } : { x: string; y: (s: string) => string; }
|
||
|
>x : string
|
||
|
>y : (s: string) => string
|
||
|
>(s: string) => { return s; } : (s: string) => string
|
||
|
>s : string
|
||
|
>s : string
|
||
|
|
||
|
// string type expressions
|
||
|
var ResultIsAny6 = void objA.a;
|
||
|
>ResultIsAny6 : any
|
||
|
>void objA.a : undefined
|
||
|
>objA.a : string
|
||
|
>objA : A
|
||
|
>a : string
|
||
|
|
||
|
var ResultIsAny7 = void M.n;
|
||
|
>ResultIsAny7 : any
|
||
|
>void M.n : undefined
|
||
|
>M.n : string
|
||
|
>M : typeof M
|
||
|
>n : string
|
||
|
|
||
|
var ResultIsAny8 = void STRING1[0];
|
||
|
>ResultIsAny8 : any
|
||
|
>void STRING1[0] : undefined
|
||
|
>STRING1[0] : string
|
||
|
>STRING1 : string[]
|
||
|
|
||
|
var ResultIsAny9 = void foo();
|
||
|
>ResultIsAny9 : any
|
||
|
>void foo() : undefined
|
||
|
>foo() : string
|
||
|
>foo : () => string
|
||
|
|
||
|
var ResultIsAny10 = void A.foo();
|
||
|
>ResultIsAny10 : any
|
||
|
>void A.foo() : undefined
|
||
|
>A.foo() : string
|
||
|
>A.foo : () => string
|
||
|
>A : typeof A
|
||
|
>foo : () => string
|
||
|
|
||
|
var ResultIsAny11 = void (STRING + STRING);
|
||
|
>ResultIsAny11 : any
|
||
|
>void (STRING + STRING) : undefined
|
||
|
>(STRING + STRING) : string
|
||
|
>STRING + STRING : string
|
||
|
>STRING : string
|
||
|
>STRING : string
|
||
|
|
||
|
var ResultIsAny12 = void STRING.charAt(0);
|
||
|
>ResultIsAny12 : any
|
||
|
>void STRING.charAt(0) : undefined
|
||
|
>STRING.charAt(0) : string
|
||
|
>STRING.charAt : (pos: number) => string
|
||
|
>STRING : string
|
||
|
>charAt : (pos: number) => string
|
||
|
|
||
|
// multiple void operators
|
||
|
var ResultIsAny13 = void void STRING;
|
||
|
>ResultIsAny13 : any
|
||
|
>void void STRING : undefined
|
||
|
>void STRING : undefined
|
||
|
>STRING : string
|
||
|
|
||
|
var ResultIsAny14 = void void void (STRING + STRING);
|
||
|
>ResultIsAny14 : any
|
||
|
>void void void (STRING + STRING) : undefined
|
||
|
>void void (STRING + STRING) : undefined
|
||
|
>void (STRING + STRING) : undefined
|
||
|
>(STRING + STRING) : string
|
||
|
>STRING + STRING : string
|
||
|
>STRING : string
|
||
|
>STRING : string
|
||
|
|
||
|
// miss assignment operators
|
||
|
void "";
|
||
|
>void "" : undefined
|
||
|
|
||
|
void STRING;
|
||
|
>void STRING : undefined
|
||
|
>STRING : string
|
||
|
|
||
|
void STRING1;
|
||
|
>void STRING1 : undefined
|
||
|
>STRING1 : string[]
|
||
|
|
||
|
void foo();
|
||
|
>void foo() : undefined
|
||
|
>foo() : string
|
||
|
>foo : () => string
|
||
|
|
||
|
void objA.a,M.n;
|
||
|
>void objA.a,M.n : string
|
||
|
>void objA.a : undefined
|
||
|
>objA.a : string
|
||
|
>objA : A
|
||
|
>a : string
|
||
|
>M.n : string
|
||
|
>M : typeof M
|
||
|
>n : string
|
||
|
|