TypeScript/tests/baselines/reference/typeofOperatorWithStringType.types

233 lines
9.2 KiB
Text

=== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithStringType.ts ===
// typeof operator on string type
var STRING: string;
>STRING : string, Symbol(STRING,Decl(typeofOperatorWithStringType.ts,1,3))
var STRING1: string[] = ["", "abc"];
>STRING1 : string[], Symbol(STRING1,Decl(typeofOperatorWithStringType.ts,2,3))
>["", "abc"] : string[]
>"" : string
>"abc" : string
function foo(): string { return "abc"; }
>foo : () => string, Symbol(foo,Decl(typeofOperatorWithStringType.ts,2,36))
>"abc" : string
class A {
>A : A, Symbol(A,Decl(typeofOperatorWithStringType.ts,4,40))
public a: string;
>a : string, Symbol(a,Decl(typeofOperatorWithStringType.ts,6,9))
static foo() { return ""; }
>foo : () => string, Symbol(A.foo,Decl(typeofOperatorWithStringType.ts,7,21))
>"" : string
}
module M {
>M : typeof M, Symbol(M,Decl(typeofOperatorWithStringType.ts,9,1))
export var n: string;
>n : string, Symbol(n,Decl(typeofOperatorWithStringType.ts,11,14))
}
var objA = new A();
>objA : A, Symbol(objA,Decl(typeofOperatorWithStringType.ts,14,3))
>new A() : A
>A : typeof A, Symbol(A,Decl(typeofOperatorWithStringType.ts,4,40))
// string type var
var ResultIsString1 = typeof STRING;
>ResultIsString1 : string, Symbol(ResultIsString1,Decl(typeofOperatorWithStringType.ts,17,3))
>typeof STRING : string
>STRING : string, Symbol(STRING,Decl(typeofOperatorWithStringType.ts,1,3))
var ResultIsString2 = typeof STRING1;
>ResultIsString2 : string, Symbol(ResultIsString2,Decl(typeofOperatorWithStringType.ts,18,3))
>typeof STRING1 : string
>STRING1 : string[], Symbol(STRING1,Decl(typeofOperatorWithStringType.ts,2,3))
// string type literal
var ResultIsString3 = typeof "";
>ResultIsString3 : string, Symbol(ResultIsString3,Decl(typeofOperatorWithStringType.ts,21,3))
>typeof "" : string
>"" : string
var ResultIsString4 = typeof { x: "", y: "" };
>ResultIsString4 : string, Symbol(ResultIsString4,Decl(typeofOperatorWithStringType.ts,22,3))
>typeof { x: "", y: "" } : string
>{ x: "", y: "" } : { x: string; y: string; }
>x : string, Symbol(x,Decl(typeofOperatorWithStringType.ts,22,30))
>"" : string
>y : string, Symbol(y,Decl(typeofOperatorWithStringType.ts,22,37))
>"" : string
var ResultIsString5 = typeof { x: "", y: (s: string) => { return s; } };
>ResultIsString5 : string, Symbol(ResultIsString5,Decl(typeofOperatorWithStringType.ts,23,3))
>typeof { x: "", y: (s: string) => { return s; } } : string
>{ x: "", y: (s: string) => { return s; } } : { x: string; y: (s: string) => string; }
>x : string, Symbol(x,Decl(typeofOperatorWithStringType.ts,23,30))
>"" : string
>y : (s: string) => string, Symbol(y,Decl(typeofOperatorWithStringType.ts,23,37))
>(s: string) => { return s; } : (s: string) => string
>s : string, Symbol(s,Decl(typeofOperatorWithStringType.ts,23,42))
>s : string, Symbol(s,Decl(typeofOperatorWithStringType.ts,23,42))
// string type expressions
var ResultIsString6 = typeof objA.a;
>ResultIsString6 : string, Symbol(ResultIsString6,Decl(typeofOperatorWithStringType.ts,26,3))
>typeof objA.a : string
>objA.a : string, Symbol(A.a,Decl(typeofOperatorWithStringType.ts,6,9))
>objA : A, Symbol(objA,Decl(typeofOperatorWithStringType.ts,14,3))
>a : string, Symbol(A.a,Decl(typeofOperatorWithStringType.ts,6,9))
var ResultIsString7 = typeof M.n;
>ResultIsString7 : string, Symbol(ResultIsString7,Decl(typeofOperatorWithStringType.ts,27,3))
>typeof M.n : string
>M.n : string, Symbol(M.n,Decl(typeofOperatorWithStringType.ts,11,14))
>M : typeof M, Symbol(M,Decl(typeofOperatorWithStringType.ts,9,1))
>n : string, Symbol(M.n,Decl(typeofOperatorWithStringType.ts,11,14))
var ResultIsString8 = typeof STRING1[0];
>ResultIsString8 : string, Symbol(ResultIsString8,Decl(typeofOperatorWithStringType.ts,28,3))
>typeof STRING1[0] : string
>STRING1[0] : string
>STRING1 : string[], Symbol(STRING1,Decl(typeofOperatorWithStringType.ts,2,3))
>0 : number
var ResultIsString9 = typeof foo();
>ResultIsString9 : string, Symbol(ResultIsString9,Decl(typeofOperatorWithStringType.ts,29,3))
>typeof foo() : string
>foo() : string
>foo : () => string, Symbol(foo,Decl(typeofOperatorWithStringType.ts,2,36))
var ResultIsString10 = typeof A.foo();
>ResultIsString10 : string, Symbol(ResultIsString10,Decl(typeofOperatorWithStringType.ts,30,3))
>typeof A.foo() : string
>A.foo() : string
>A.foo : () => string, Symbol(A.foo,Decl(typeofOperatorWithStringType.ts,7,21))
>A : typeof A, Symbol(A,Decl(typeofOperatorWithStringType.ts,4,40))
>foo : () => string, Symbol(A.foo,Decl(typeofOperatorWithStringType.ts,7,21))
var ResultIsString11 = typeof (STRING + STRING);
>ResultIsString11 : string, Symbol(ResultIsString11,Decl(typeofOperatorWithStringType.ts,31,3))
>typeof (STRING + STRING) : string
>(STRING + STRING) : string
>STRING + STRING : string
>STRING : string, Symbol(STRING,Decl(typeofOperatorWithStringType.ts,1,3))
>STRING : string, Symbol(STRING,Decl(typeofOperatorWithStringType.ts,1,3))
var ResultIsString12 = typeof STRING.charAt(0);
>ResultIsString12 : string, Symbol(ResultIsString12,Decl(typeofOperatorWithStringType.ts,32,3))
>typeof STRING.charAt(0) : string
>STRING.charAt(0) : string
>STRING.charAt : (pos: number) => string, Symbol(String.charAt,Decl(lib.d.ts,279,23))
>STRING : string, Symbol(STRING,Decl(typeofOperatorWithStringType.ts,1,3))
>charAt : (pos: number) => string, Symbol(String.charAt,Decl(lib.d.ts,279,23))
>0 : number
// multiple typeof operators
var ResultIsString13 = typeof typeof STRING;
>ResultIsString13 : string, Symbol(ResultIsString13,Decl(typeofOperatorWithStringType.ts,35,3))
>typeof typeof STRING : string
>typeof STRING : string
>STRING : string, Symbol(STRING,Decl(typeofOperatorWithStringType.ts,1,3))
var ResultIsString14 = typeof typeof typeof (STRING + STRING);
>ResultIsString14 : string, Symbol(ResultIsString14,Decl(typeofOperatorWithStringType.ts,36,3))
>typeof typeof typeof (STRING + STRING) : string
>typeof typeof (STRING + STRING) : string
>typeof (STRING + STRING) : string
>(STRING + STRING) : string
>STRING + STRING : string
>STRING : string, Symbol(STRING,Decl(typeofOperatorWithStringType.ts,1,3))
>STRING : string, Symbol(STRING,Decl(typeofOperatorWithStringType.ts,1,3))
// miss assignment operators
typeof "";
>typeof "" : string
>"" : string
typeof STRING;
>typeof STRING : string
>STRING : string, Symbol(STRING,Decl(typeofOperatorWithStringType.ts,1,3))
typeof STRING1;
>typeof STRING1 : string
>STRING1 : string[], Symbol(STRING1,Decl(typeofOperatorWithStringType.ts,2,3))
typeof foo();
>typeof foo() : string
>foo() : string
>foo : () => string, Symbol(foo,Decl(typeofOperatorWithStringType.ts,2,36))
typeof objA.a, M.n;
>typeof objA.a, M.n : string
>typeof objA.a : string
>objA.a : string, Symbol(A.a,Decl(typeofOperatorWithStringType.ts,6,9))
>objA : A, Symbol(objA,Decl(typeofOperatorWithStringType.ts,14,3))
>a : string, Symbol(A.a,Decl(typeofOperatorWithStringType.ts,6,9))
>M.n : string, Symbol(M.n,Decl(typeofOperatorWithStringType.ts,11,14))
>M : typeof M, Symbol(M,Decl(typeofOperatorWithStringType.ts,9,1))
>n : string, Symbol(M.n,Decl(typeofOperatorWithStringType.ts,11,14))
// use typeof in type query
var z: string;
>z : string, Symbol(z,Decl(typeofOperatorWithStringType.ts,46,3))
var x: string[];
>x : string[], Symbol(x,Decl(typeofOperatorWithStringType.ts,47,3))
var r: () => string;
>r : () => string, Symbol(r,Decl(typeofOperatorWithStringType.ts,48,3))
z: typeof STRING;
>z : any
>typeof STRING : string
>STRING : string, Symbol(STRING,Decl(typeofOperatorWithStringType.ts,1,3))
x: typeof STRING1;
>x : any
>typeof STRING1 : string
>STRING1 : string[], Symbol(STRING1,Decl(typeofOperatorWithStringType.ts,2,3))
r: typeof foo;
>r : any
>typeof foo : string
>foo : () => string, Symbol(foo,Decl(typeofOperatorWithStringType.ts,2,36))
var y = { a: "", b: "" };
>y : { a: string; b: string; }, Symbol(y,Decl(typeofOperatorWithStringType.ts,52,3))
>{ a: "", b: "" } : { a: string; b: string; }
>a : string, Symbol(a,Decl(typeofOperatorWithStringType.ts,52,9))
>"" : string
>b : string, Symbol(b,Decl(typeofOperatorWithStringType.ts,52,16))
>"" : string
z: typeof y.a;
>z : any
>typeof y.a : string
>y.a : string, Symbol(a,Decl(typeofOperatorWithStringType.ts,52,9))
>y : { a: string; b: string; }, Symbol(y,Decl(typeofOperatorWithStringType.ts,52,3))
>a : string, Symbol(a,Decl(typeofOperatorWithStringType.ts,52,9))
z: typeof objA.a;
>z : any
>typeof objA.a : string
>objA.a : string, Symbol(A.a,Decl(typeofOperatorWithStringType.ts,6,9))
>objA : A, Symbol(objA,Decl(typeofOperatorWithStringType.ts,14,3))
>a : string, Symbol(A.a,Decl(typeofOperatorWithStringType.ts,6,9))
z: typeof A.foo;
>z : any
>typeof A.foo : string
>A.foo : () => string, Symbol(A.foo,Decl(typeofOperatorWithStringType.ts,7,21))
>A : typeof A, Symbol(A,Decl(typeofOperatorWithStringType.ts,4,40))
>foo : () => string, Symbol(A.foo,Decl(typeofOperatorWithStringType.ts,7,21))
z: typeof M.n;
>z : any
>typeof M.n : string
>M.n : string, Symbol(M.n,Decl(typeofOperatorWithStringType.ts,11,14))
>M : typeof M, Symbol(M,Decl(typeofOperatorWithStringType.ts,9,1))
>n : string, Symbol(M.n,Decl(typeofOperatorWithStringType.ts,11,14))