2014-08-15 23:33:16 +02:00
|
|
|
=== tests/cases/conformance/expressions/unaryOperators/typeofOperator/typeofOperatorWithNumberType.ts ===
|
|
|
|
// typeof operator on number type
|
|
|
|
var NUMBER: number;
|
2015-04-13 22:54:22 +02:00
|
|
|
>NUMBER : number, Symbol(NUMBER,Decl(typeofOperatorWithNumberType.ts,1,3))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var NUMBER1: number[] = [1, 2];
|
2015-04-13 22:54:22 +02:00
|
|
|
>NUMBER1 : number[], Symbol(NUMBER1,Decl(typeofOperatorWithNumberType.ts,2,3))
|
2014-08-15 23:33:16 +02:00
|
|
|
>[1, 2] : number[]
|
2015-04-13 21:36:11 +02:00
|
|
|
>1 : number
|
|
|
|
>2 : number
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
function foo(): number { return 1; }
|
2015-04-13 22:54:22 +02:00
|
|
|
>foo : () => number, Symbol(foo,Decl(typeofOperatorWithNumberType.ts,2,31))
|
2015-04-13 21:36:11 +02:00
|
|
|
>1 : number
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
class A {
|
2015-04-13 22:54:22 +02:00
|
|
|
>A : A, Symbol(A,Decl(typeofOperatorWithNumberType.ts,4,36))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
public a: number;
|
2015-04-13 22:54:22 +02:00
|
|
|
>a : number, Symbol(a,Decl(typeofOperatorWithNumberType.ts,6,9))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
static foo() { return 1; }
|
2015-04-13 22:54:22 +02:00
|
|
|
>foo : () => number, Symbol(A.foo,Decl(typeofOperatorWithNumberType.ts,7,21))
|
2015-04-13 21:36:11 +02:00
|
|
|
>1 : number
|
2014-08-15 23:33:16 +02:00
|
|
|
}
|
|
|
|
module M {
|
2015-04-13 22:54:22 +02:00
|
|
|
>M : typeof M, Symbol(M,Decl(typeofOperatorWithNumberType.ts,9,1))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
export var n: number;
|
2015-04-13 22:54:22 +02:00
|
|
|
>n : number, Symbol(n,Decl(typeofOperatorWithNumberType.ts,11,14))
|
2014-08-15 23:33:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var objA = new A();
|
2015-04-13 22:54:22 +02:00
|
|
|
>objA : A, Symbol(objA,Decl(typeofOperatorWithNumberType.ts,14,3))
|
2014-08-15 23:33:16 +02:00
|
|
|
>new A() : A
|
2015-04-13 22:54:22 +02:00
|
|
|
>A : typeof A, Symbol(A,Decl(typeofOperatorWithNumberType.ts,4,36))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
// number type var
|
|
|
|
var ResultIsString1 = typeof NUMBER;
|
2015-04-13 22:54:22 +02:00
|
|
|
>ResultIsString1 : string, Symbol(ResultIsString1,Decl(typeofOperatorWithNumberType.ts,17,3))
|
2014-08-15 23:33:16 +02:00
|
|
|
>typeof NUMBER : string
|
2015-04-13 22:54:22 +02:00
|
|
|
>NUMBER : number, Symbol(NUMBER,Decl(typeofOperatorWithNumberType.ts,1,3))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var ResultIsString2 = typeof NUMBER1;
|
2015-04-13 22:54:22 +02:00
|
|
|
>ResultIsString2 : string, Symbol(ResultIsString2,Decl(typeofOperatorWithNumberType.ts,18,3))
|
2014-08-15 23:33:16 +02:00
|
|
|
>typeof NUMBER1 : string
|
2015-04-13 22:54:22 +02:00
|
|
|
>NUMBER1 : number[], Symbol(NUMBER1,Decl(typeofOperatorWithNumberType.ts,2,3))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
// number type literal
|
|
|
|
var ResultIsString3 = typeof 1;
|
2015-04-13 22:54:22 +02:00
|
|
|
>ResultIsString3 : string, Symbol(ResultIsString3,Decl(typeofOperatorWithNumberType.ts,21,3))
|
2014-08-15 23:33:16 +02:00
|
|
|
>typeof 1 : string
|
2015-04-13 21:36:11 +02:00
|
|
|
>1 : number
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var ResultIsString4 = typeof { x: 1, y: 2};
|
2015-04-13 22:54:22 +02:00
|
|
|
>ResultIsString4 : string, Symbol(ResultIsString4,Decl(typeofOperatorWithNumberType.ts,22,3))
|
2014-08-15 23:33:16 +02:00
|
|
|
>typeof { x: 1, y: 2} : string
|
|
|
|
>{ x: 1, y: 2} : { x: number; y: number; }
|
2015-04-13 22:54:22 +02:00
|
|
|
>x : number, Symbol(x,Decl(typeofOperatorWithNumberType.ts,22,30))
|
2015-04-13 21:36:11 +02:00
|
|
|
>1 : number
|
2015-04-13 22:54:22 +02:00
|
|
|
>y : number, Symbol(y,Decl(typeofOperatorWithNumberType.ts,22,36))
|
2015-04-13 21:36:11 +02:00
|
|
|
>2 : number
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var ResultIsString5 = typeof { x: 1, y: (n: number) => { return n; } };
|
2015-04-13 22:54:22 +02:00
|
|
|
>ResultIsString5 : string, Symbol(ResultIsString5,Decl(typeofOperatorWithNumberType.ts,23,3))
|
2014-08-15 23:33:16 +02:00
|
|
|
>typeof { x: 1, y: (n: number) => { return n; } } : string
|
|
|
|
>{ x: 1, y: (n: number) => { return n; } } : { x: number; y: (n: number) => number; }
|
2015-04-13 22:54:22 +02:00
|
|
|
>x : number, Symbol(x,Decl(typeofOperatorWithNumberType.ts,23,30))
|
2015-04-13 21:36:11 +02:00
|
|
|
>1 : number
|
2015-04-13 22:54:22 +02:00
|
|
|
>y : (n: number) => number, Symbol(y,Decl(typeofOperatorWithNumberType.ts,23,36))
|
2014-08-15 23:33:16 +02:00
|
|
|
>(n: number) => { return n; } : (n: number) => number
|
2015-04-13 22:54:22 +02:00
|
|
|
>n : number, Symbol(n,Decl(typeofOperatorWithNumberType.ts,23,41))
|
|
|
|
>n : number, Symbol(n,Decl(typeofOperatorWithNumberType.ts,23,41))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
// number type expressions
|
|
|
|
var ResultIsString6 = typeof objA.a;
|
2015-04-13 22:54:22 +02:00
|
|
|
>ResultIsString6 : string, Symbol(ResultIsString6,Decl(typeofOperatorWithNumberType.ts,26,3))
|
2014-08-15 23:33:16 +02:00
|
|
|
>typeof objA.a : string
|
2015-04-13 22:54:22 +02:00
|
|
|
>objA.a : number, Symbol(A.a,Decl(typeofOperatorWithNumberType.ts,6,9))
|
|
|
|
>objA : A, Symbol(objA,Decl(typeofOperatorWithNumberType.ts,14,3))
|
|
|
|
>a : number, Symbol(A.a,Decl(typeofOperatorWithNumberType.ts,6,9))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var ResultIsString7 = typeof M.n;
|
2015-04-13 22:54:22 +02:00
|
|
|
>ResultIsString7 : string, Symbol(ResultIsString7,Decl(typeofOperatorWithNumberType.ts,27,3))
|
2014-08-15 23:33:16 +02:00
|
|
|
>typeof M.n : string
|
2015-04-13 22:54:22 +02:00
|
|
|
>M.n : number, Symbol(M.n,Decl(typeofOperatorWithNumberType.ts,11,14))
|
|
|
|
>M : typeof M, Symbol(M,Decl(typeofOperatorWithNumberType.ts,9,1))
|
|
|
|
>n : number, Symbol(M.n,Decl(typeofOperatorWithNumberType.ts,11,14))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var ResultIsString8 = typeof NUMBER1[0];
|
2015-04-13 22:54:22 +02:00
|
|
|
>ResultIsString8 : string, Symbol(ResultIsString8,Decl(typeofOperatorWithNumberType.ts,28,3))
|
2014-08-15 23:33:16 +02:00
|
|
|
>typeof NUMBER1[0] : string
|
|
|
|
>NUMBER1[0] : number
|
2015-04-13 22:54:22 +02:00
|
|
|
>NUMBER1 : number[], Symbol(NUMBER1,Decl(typeofOperatorWithNumberType.ts,2,3))
|
2015-04-13 21:36:11 +02:00
|
|
|
>0 : number
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var ResultIsString9 = typeof foo();
|
2015-04-13 22:54:22 +02:00
|
|
|
>ResultIsString9 : string, Symbol(ResultIsString9,Decl(typeofOperatorWithNumberType.ts,29,3))
|
2014-08-15 23:33:16 +02:00
|
|
|
>typeof foo() : string
|
|
|
|
>foo() : number
|
2015-04-13 22:54:22 +02:00
|
|
|
>foo : () => number, Symbol(foo,Decl(typeofOperatorWithNumberType.ts,2,31))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var ResultIsString10 = typeof A.foo();
|
2015-04-13 22:54:22 +02:00
|
|
|
>ResultIsString10 : string, Symbol(ResultIsString10,Decl(typeofOperatorWithNumberType.ts,30,3))
|
2014-08-15 23:33:16 +02:00
|
|
|
>typeof A.foo() : string
|
|
|
|
>A.foo() : number
|
2015-04-13 22:54:22 +02:00
|
|
|
>A.foo : () => number, Symbol(A.foo,Decl(typeofOperatorWithNumberType.ts,7,21))
|
|
|
|
>A : typeof A, Symbol(A,Decl(typeofOperatorWithNumberType.ts,4,36))
|
|
|
|
>foo : () => number, Symbol(A.foo,Decl(typeofOperatorWithNumberType.ts,7,21))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var ResultIsString11 = typeof (NUMBER + NUMBER);
|
2015-04-13 22:54:22 +02:00
|
|
|
>ResultIsString11 : string, Symbol(ResultIsString11,Decl(typeofOperatorWithNumberType.ts,31,3))
|
2014-08-15 23:33:16 +02:00
|
|
|
>typeof (NUMBER + NUMBER) : string
|
|
|
|
>(NUMBER + NUMBER) : number
|
|
|
|
>NUMBER + NUMBER : number
|
2015-04-13 22:54:22 +02:00
|
|
|
>NUMBER : number, Symbol(NUMBER,Decl(typeofOperatorWithNumberType.ts,1,3))
|
|
|
|
>NUMBER : number, Symbol(NUMBER,Decl(typeofOperatorWithNumberType.ts,1,3))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
// multiple typeof operators
|
|
|
|
var ResultIsString12 = typeof typeof NUMBER;
|
2015-04-13 22:54:22 +02:00
|
|
|
>ResultIsString12 : string, Symbol(ResultIsString12,Decl(typeofOperatorWithNumberType.ts,34,3))
|
2014-08-15 23:33:16 +02:00
|
|
|
>typeof typeof NUMBER : string
|
|
|
|
>typeof NUMBER : string
|
2015-04-13 22:54:22 +02:00
|
|
|
>NUMBER : number, Symbol(NUMBER,Decl(typeofOperatorWithNumberType.ts,1,3))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var ResultIsString13 = typeof typeof typeof (NUMBER + NUMBER);
|
2015-04-13 22:54:22 +02:00
|
|
|
>ResultIsString13 : string, Symbol(ResultIsString13,Decl(typeofOperatorWithNumberType.ts,35,3))
|
2014-08-15 23:33:16 +02:00
|
|
|
>typeof typeof typeof (NUMBER + NUMBER) : string
|
|
|
|
>typeof typeof (NUMBER + NUMBER) : string
|
|
|
|
>typeof (NUMBER + NUMBER) : string
|
|
|
|
>(NUMBER + NUMBER) : number
|
|
|
|
>NUMBER + NUMBER : number
|
2015-04-13 22:54:22 +02:00
|
|
|
>NUMBER : number, Symbol(NUMBER,Decl(typeofOperatorWithNumberType.ts,1,3))
|
|
|
|
>NUMBER : number, Symbol(NUMBER,Decl(typeofOperatorWithNumberType.ts,1,3))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
// miss assignment operators
|
|
|
|
typeof 1;
|
|
|
|
>typeof 1 : string
|
2015-04-13 21:36:11 +02:00
|
|
|
>1 : number
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
typeof NUMBER;
|
|
|
|
>typeof NUMBER : string
|
2015-04-13 22:54:22 +02:00
|
|
|
>NUMBER : number, Symbol(NUMBER,Decl(typeofOperatorWithNumberType.ts,1,3))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
typeof NUMBER1;
|
|
|
|
>typeof NUMBER1 : string
|
2015-04-13 22:54:22 +02:00
|
|
|
>NUMBER1 : number[], Symbol(NUMBER1,Decl(typeofOperatorWithNumberType.ts,2,3))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
typeof foo();
|
|
|
|
>typeof foo() : string
|
|
|
|
>foo() : number
|
2015-04-13 22:54:22 +02:00
|
|
|
>foo : () => number, Symbol(foo,Decl(typeofOperatorWithNumberType.ts,2,31))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
typeof objA.a;
|
|
|
|
>typeof objA.a : string
|
2015-04-13 22:54:22 +02:00
|
|
|
>objA.a : number, Symbol(A.a,Decl(typeofOperatorWithNumberType.ts,6,9))
|
|
|
|
>objA : A, Symbol(objA,Decl(typeofOperatorWithNumberType.ts,14,3))
|
|
|
|
>a : number, Symbol(A.a,Decl(typeofOperatorWithNumberType.ts,6,9))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
typeof M.n;
|
|
|
|
>typeof M.n : string
|
2015-04-13 22:54:22 +02:00
|
|
|
>M.n : number, Symbol(M.n,Decl(typeofOperatorWithNumberType.ts,11,14))
|
|
|
|
>M : typeof M, Symbol(M,Decl(typeofOperatorWithNumberType.ts,9,1))
|
|
|
|
>n : number, Symbol(M.n,Decl(typeofOperatorWithNumberType.ts,11,14))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
typeof objA.a, M.n;
|
|
|
|
>typeof objA.a, M.n : number
|
|
|
|
>typeof objA.a : string
|
2015-04-13 22:54:22 +02:00
|
|
|
>objA.a : number, Symbol(A.a,Decl(typeofOperatorWithNumberType.ts,6,9))
|
|
|
|
>objA : A, Symbol(objA,Decl(typeofOperatorWithNumberType.ts,14,3))
|
|
|
|
>a : number, Symbol(A.a,Decl(typeofOperatorWithNumberType.ts,6,9))
|
|
|
|
>M.n : number, Symbol(M.n,Decl(typeofOperatorWithNumberType.ts,11,14))
|
|
|
|
>M : typeof M, Symbol(M,Decl(typeofOperatorWithNumberType.ts,9,1))
|
|
|
|
>n : number, Symbol(M.n,Decl(typeofOperatorWithNumberType.ts,11,14))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
// use typeof in type query
|
|
|
|
var z: number;
|
2015-04-13 22:54:22 +02:00
|
|
|
>z : number, Symbol(z,Decl(typeofOperatorWithNumberType.ts,47,3))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var x: number[];
|
2015-04-13 22:54:22 +02:00
|
|
|
>x : number[], Symbol(x,Decl(typeofOperatorWithNumberType.ts,48,3))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
z: typeof NUMBER;
|
2015-04-13 22:54:22 +02:00
|
|
|
>z : any
|
2014-08-15 23:33:16 +02:00
|
|
|
>typeof NUMBER : string
|
2015-04-13 22:54:22 +02:00
|
|
|
>NUMBER : number, Symbol(NUMBER,Decl(typeofOperatorWithNumberType.ts,1,3))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
x: typeof NUMBER1;
|
2015-04-13 22:54:22 +02:00
|
|
|
>x : any
|
2014-08-15 23:33:16 +02:00
|
|
|
>typeof NUMBER1 : string
|
2015-04-13 22:54:22 +02:00
|
|
|
>NUMBER1 : number[], Symbol(NUMBER1,Decl(typeofOperatorWithNumberType.ts,2,3))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
r: typeof foo;
|
2015-04-13 22:54:22 +02:00
|
|
|
>r : any
|
2014-08-15 23:33:16 +02:00
|
|
|
>typeof foo : string
|
2015-04-13 22:54:22 +02:00
|
|
|
>foo : () => number, Symbol(foo,Decl(typeofOperatorWithNumberType.ts,2,31))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var y = { a: 1, b: 2 };
|
2015-04-13 22:54:22 +02:00
|
|
|
>y : { a: number; b: number; }, Symbol(y,Decl(typeofOperatorWithNumberType.ts,52,3))
|
2014-08-15 23:33:16 +02:00
|
|
|
>{ a: 1, b: 2 } : { a: number; b: number; }
|
2015-04-13 22:54:22 +02:00
|
|
|
>a : number, Symbol(a,Decl(typeofOperatorWithNumberType.ts,52,9))
|
2015-04-13 21:36:11 +02:00
|
|
|
>1 : number
|
2015-04-13 22:54:22 +02:00
|
|
|
>b : number, Symbol(b,Decl(typeofOperatorWithNumberType.ts,52,15))
|
2015-04-13 21:36:11 +02:00
|
|
|
>2 : number
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
z: typeof y.a;
|
2015-04-13 22:54:22 +02:00
|
|
|
>z : any
|
2014-08-15 23:33:16 +02:00
|
|
|
>typeof y.a : string
|
2015-04-13 22:54:22 +02:00
|
|
|
>y.a : number, Symbol(a,Decl(typeofOperatorWithNumberType.ts,52,9))
|
|
|
|
>y : { a: number; b: number; }, Symbol(y,Decl(typeofOperatorWithNumberType.ts,52,3))
|
|
|
|
>a : number, Symbol(a,Decl(typeofOperatorWithNumberType.ts,52,9))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
z: typeof objA.a;
|
2015-04-13 22:54:22 +02:00
|
|
|
>z : any
|
2014-08-15 23:33:16 +02:00
|
|
|
>typeof objA.a : string
|
2015-04-13 22:54:22 +02:00
|
|
|
>objA.a : number, Symbol(A.a,Decl(typeofOperatorWithNumberType.ts,6,9))
|
|
|
|
>objA : A, Symbol(objA,Decl(typeofOperatorWithNumberType.ts,14,3))
|
|
|
|
>a : number, Symbol(A.a,Decl(typeofOperatorWithNumberType.ts,6,9))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
z: typeof A.foo;
|
2015-04-13 22:54:22 +02:00
|
|
|
>z : any
|
2014-08-15 23:33:16 +02:00
|
|
|
>typeof A.foo : string
|
2015-04-13 22:54:22 +02:00
|
|
|
>A.foo : () => number, Symbol(A.foo,Decl(typeofOperatorWithNumberType.ts,7,21))
|
|
|
|
>A : typeof A, Symbol(A,Decl(typeofOperatorWithNumberType.ts,4,36))
|
|
|
|
>foo : () => number, Symbol(A.foo,Decl(typeofOperatorWithNumberType.ts,7,21))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
z: typeof M.n;
|
2015-04-13 22:54:22 +02:00
|
|
|
>z : any
|
2014-08-15 23:33:16 +02:00
|
|
|
>typeof M.n : string
|
2015-04-13 22:54:22 +02:00
|
|
|
>M.n : number, Symbol(M.n,Decl(typeofOperatorWithNumberType.ts,11,14))
|
|
|
|
>M : typeof M, Symbol(M,Decl(typeofOperatorWithNumberType.ts,9,1))
|
|
|
|
>n : number, Symbol(M.n,Decl(typeofOperatorWithNumberType.ts,11,14))
|
2014-08-15 23:33:16 +02:00
|
|
|
|