TypeScript/tests/baselines/reference/typeofOperatorWithStringType.types

234 lines
4.6 KiB
Plaintext
Raw Normal View History

2014-08-15 23:33:16 +02:00
=== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithStringType.ts ===
// typeof operator on string type
var STRING: string;
>STRING : string
2014-08-15 23:33:16 +02:00
var STRING1: string[] = ["", "abc"];
>STRING1 : string[]
2014-08-15 23:33:16 +02:00
>["", "abc"] : string[]
2015-04-13 21:36:11 +02:00
>"" : string
>"abc" : string
2014-08-15 23:33:16 +02:00
function foo(): string { return "abc"; }
>foo : () => string
2015-04-13 21:36:11 +02:00
>"abc" : string
2014-08-15 23:33:16 +02:00
class A {
>A : A
2014-08-15 23:33:16 +02:00
public a: string;
>a : string
2014-08-15 23:33:16 +02:00
static foo() { return ""; }
>foo : () => string
2015-04-13 21:36:11 +02:00
>"" : string
2014-08-15 23:33:16 +02:00
}
module M {
>M : typeof M
2014-08-15 23:33:16 +02:00
export var n: string;
>n : string
2014-08-15 23:33:16 +02:00
}
var objA = new A();
>objA : A
2014-08-15 23:33:16 +02:00
>new A() : A
>A : typeof A
2014-08-15 23:33:16 +02:00
// string type var
var ResultIsString1 = typeof STRING;
>ResultIsString1 : string
2014-08-15 23:33:16 +02:00
>typeof STRING : string
>STRING : string
2014-08-15 23:33:16 +02:00
var ResultIsString2 = typeof STRING1;
>ResultIsString2 : string
2014-08-15 23:33:16 +02:00
>typeof STRING1 : string
>STRING1 : string[]
2014-08-15 23:33:16 +02:00
// string type literal
var ResultIsString3 = typeof "";
>ResultIsString3 : string
2014-08-15 23:33:16 +02:00
>typeof "" : string
2015-04-13 21:36:11 +02:00
>"" : string
2014-08-15 23:33:16 +02:00
var ResultIsString4 = typeof { x: "", y: "" };
>ResultIsString4 : string
2014-08-15 23:33:16 +02:00
>typeof { x: "", y: "" } : string
>{ x: "", y: "" } : { x: string; y: string; }
>x : string
2015-04-13 21:36:11 +02:00
>"" : string
>y : string
2015-04-13 21:36:11 +02:00
>"" : string
2014-08-15 23:33:16 +02:00
var ResultIsString5 = typeof { x: "", y: (s: string) => { return s; } };
>ResultIsString5 : string
2014-08-15 23:33:16 +02:00
>typeof { x: "", y: (s: string) => { return s; } } : string
>{ x: "", y: (s: string) => { return s; } } : { x: string; y: (s: string) => string; }
>x : string
2015-04-13 21:36:11 +02:00
>"" : string
>y : (s: string) => string
2014-08-15 23:33:16 +02:00
>(s: string) => { return s; } : (s: string) => string
>s : string
>s : string
2014-08-15 23:33:16 +02:00
// string type expressions
var ResultIsString6 = typeof objA.a;
>ResultIsString6 : string
2014-08-15 23:33:16 +02:00
>typeof objA.a : string
>objA.a : string
>objA : A
>a : string
2014-08-15 23:33:16 +02:00
var ResultIsString7 = typeof M.n;
>ResultIsString7 : string
2014-08-15 23:33:16 +02:00
>typeof M.n : string
>M.n : string
>M : typeof M
>n : string
2014-08-15 23:33:16 +02:00
var ResultIsString8 = typeof STRING1[0];
>ResultIsString8 : string
2014-08-15 23:33:16 +02:00
>typeof STRING1[0] : string
>STRING1[0] : string
>STRING1 : string[]
2015-04-13 21:36:11 +02:00
>0 : number
2014-08-15 23:33:16 +02:00
var ResultIsString9 = typeof foo();
>ResultIsString9 : string
2014-08-15 23:33:16 +02:00
>typeof foo() : string
>foo() : string
>foo : () => string
2014-08-15 23:33:16 +02:00
var ResultIsString10 = typeof A.foo();
>ResultIsString10 : string
2014-08-15 23:33:16 +02:00
>typeof A.foo() : string
>A.foo() : string
>A.foo : () => string
>A : typeof A
>foo : () => string
2014-08-15 23:33:16 +02:00
var ResultIsString11 = typeof (STRING + STRING);
>ResultIsString11 : string
2014-08-15 23:33:16 +02:00
>typeof (STRING + STRING) : string
>(STRING + STRING) : string
>STRING + STRING : string
>STRING : string
>STRING : string
2014-08-15 23:33:16 +02:00
var ResultIsString12 = typeof STRING.charAt(0);
>ResultIsString12 : string
2014-08-15 23:33:16 +02:00
>typeof STRING.charAt(0) : string
>STRING.charAt(0) : string
>STRING.charAt : (pos: number) => string
>STRING : string
>charAt : (pos: number) => string
2015-04-13 21:36:11 +02:00
>0 : number
2014-08-15 23:33:16 +02:00
// multiple typeof operators
var ResultIsString13 = typeof typeof STRING;
>ResultIsString13 : string
2014-08-15 23:33:16 +02:00
>typeof typeof STRING : string
>typeof STRING : string
>STRING : string
2014-08-15 23:33:16 +02:00
var ResultIsString14 = typeof typeof typeof (STRING + STRING);
>ResultIsString14 : string
2014-08-15 23:33:16 +02:00
>typeof typeof typeof (STRING + STRING) : string
>typeof typeof (STRING + STRING) : string
>typeof (STRING + STRING) : string
>(STRING + STRING) : string
>STRING + STRING : string
>STRING : string
>STRING : string
2014-08-15 23:33:16 +02:00
// miss assignment operators
typeof "";
>typeof "" : string
2015-04-13 21:36:11 +02:00
>"" : string
2014-08-15 23:33:16 +02:00
typeof STRING;
>typeof STRING : string
>STRING : string
2014-08-15 23:33:16 +02:00
typeof STRING1;
>typeof STRING1 : string
>STRING1 : string[]
2014-08-15 23:33:16 +02:00
typeof foo();
>typeof foo() : string
>foo() : string
>foo : () => string
2014-08-15 23:33:16 +02:00
typeof objA.a, M.n;
>typeof objA.a, M.n : string
>typeof objA.a : string
>objA.a : string
>objA : A
>a : string
>M.n : string
>M : typeof M
>n : string
2014-08-15 23:33:16 +02:00
// use typeof in type query
var z: string;
>z : string
2014-08-15 23:33:16 +02:00
var x: string[];
>x : string[]
2014-08-15 23:33:16 +02:00
var r: () => string;
>r : () => string
2014-08-15 23:33:16 +02:00
z: typeof STRING;
>z : any
2014-08-15 23:33:16 +02:00
>typeof STRING : string
>STRING : string
2014-08-15 23:33:16 +02:00
x: typeof STRING1;
>x : any
2014-08-15 23:33:16 +02:00
>typeof STRING1 : string
>STRING1 : string[]
2014-08-15 23:33:16 +02:00
r: typeof foo;
>r : any
2014-08-15 23:33:16 +02:00
>typeof foo : string
>foo : () => string
2014-08-15 23:33:16 +02:00
var y = { a: "", b: "" };
>y : { a: string; b: string; }
2014-08-15 23:33:16 +02:00
>{ a: "", b: "" } : { a: string; b: string; }
>a : string
2015-04-13 21:36:11 +02:00
>"" : string
>b : string
2015-04-13 21:36:11 +02:00
>"" : string
2014-08-15 23:33:16 +02:00
z: typeof y.a;
>z : any
2014-08-15 23:33:16 +02:00
>typeof y.a : string
>y.a : string
>y : { a: string; b: string; }
>a : string
2014-08-15 23:33:16 +02:00
z: typeof objA.a;
>z : any
2014-08-15 23:33:16 +02:00
>typeof objA.a : string
>objA.a : string
>objA : A
>a : string
2014-08-15 23:33:16 +02:00
z: typeof A.foo;
>z : any
2014-08-15 23:33:16 +02:00
>typeof A.foo : string
>A.foo : () => string
>A : typeof A
>foo : () => string
2014-08-15 23:33:16 +02:00
z: typeof M.n;
>z : any
2014-08-15 23:33:16 +02:00
>typeof M.n : string
>M.n : string
>M : typeof M
>n : string
2014-08-15 23:33:16 +02:00