2014-08-15 23:33:16 +02:00
|
|
|
=== tests/cases/conformance/expressions/unaryOperators/plusOperator/plusOperatorWithStringType.ts ===
|
|
|
|
// + operator on string type
|
|
|
|
var STRING: string;
|
2015-04-13 23:01:57 +02:00
|
|
|
>STRING : string, Symbol(STRING, Decl(plusOperatorWithStringType.ts, 1, 3))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var STRING1: string[] = ["", "abc"];
|
2015-04-13 23:01:57 +02:00
|
|
|
>STRING1 : string[], Symbol(STRING1, Decl(plusOperatorWithStringType.ts, 2, 3))
|
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"; }
|
2015-04-13 23:01:57 +02:00
|
|
|
>foo : () => string, Symbol(foo, Decl(plusOperatorWithStringType.ts, 2, 36))
|
2015-04-13 21:36:11 +02:00
|
|
|
>"abc" : string
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
class A {
|
2015-04-13 23:01:57 +02:00
|
|
|
>A : A, Symbol(A, Decl(plusOperatorWithStringType.ts, 4, 40))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
public a: string;
|
2015-04-13 23:01:57 +02:00
|
|
|
>a : string, Symbol(a, Decl(plusOperatorWithStringType.ts, 6, 9))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
static foo() { return ""; }
|
2015-04-13 23:01:57 +02:00
|
|
|
>foo : () => string, Symbol(A.foo, Decl(plusOperatorWithStringType.ts, 7, 21))
|
2015-04-13 21:36:11 +02:00
|
|
|
>"" : string
|
2014-08-15 23:33:16 +02:00
|
|
|
}
|
|
|
|
module M {
|
2015-04-13 23:01:57 +02:00
|
|
|
>M : typeof M, Symbol(M, Decl(plusOperatorWithStringType.ts, 9, 1))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
export var n: string;
|
2015-04-13 23:01:57 +02:00
|
|
|
>n : string, Symbol(n, Decl(plusOperatorWithStringType.ts, 11, 14))
|
2014-08-15 23:33:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var objA = new A();
|
2015-04-13 23:01:57 +02:00
|
|
|
>objA : A, Symbol(objA, Decl(plusOperatorWithStringType.ts, 14, 3))
|
2014-08-15 23:33:16 +02:00
|
|
|
>new A() : A
|
2015-04-13 23:01:57 +02:00
|
|
|
>A : typeof A, Symbol(A, Decl(plusOperatorWithStringType.ts, 4, 40))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
// string type var
|
|
|
|
var ResultIsNumber1 = +STRING;
|
2015-04-13 23:01:57 +02:00
|
|
|
>ResultIsNumber1 : number, Symbol(ResultIsNumber1, Decl(plusOperatorWithStringType.ts, 17, 3))
|
2014-08-15 23:33:16 +02:00
|
|
|
>+STRING : number
|
2015-04-13 23:01:57 +02:00
|
|
|
>STRING : string, Symbol(STRING, Decl(plusOperatorWithStringType.ts, 1, 3))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var ResultIsNumber2 = +STRING1;
|
2015-04-13 23:01:57 +02:00
|
|
|
>ResultIsNumber2 : number, Symbol(ResultIsNumber2, Decl(plusOperatorWithStringType.ts, 18, 3))
|
2014-08-15 23:33:16 +02:00
|
|
|
>+STRING1 : number
|
2015-04-13 23:01:57 +02:00
|
|
|
>STRING1 : string[], Symbol(STRING1, Decl(plusOperatorWithStringType.ts, 2, 3))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
// string type literal
|
|
|
|
var ResultIsNumber3 = +"";
|
2015-04-13 23:01:57 +02:00
|
|
|
>ResultIsNumber3 : number, Symbol(ResultIsNumber3, Decl(plusOperatorWithStringType.ts, 21, 3))
|
2014-08-15 23:33:16 +02:00
|
|
|
>+"" : number
|
2015-04-13 21:36:11 +02:00
|
|
|
>"" : string
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var ResultIsNumber4 = +{ x: "", y: "" };
|
2015-04-13 23:01:57 +02:00
|
|
|
>ResultIsNumber4 : number, Symbol(ResultIsNumber4, Decl(plusOperatorWithStringType.ts, 22, 3))
|
2014-08-15 23:33:16 +02:00
|
|
|
>+{ x: "", y: "" } : number
|
|
|
|
>{ x: "", y: "" } : { x: string; y: string; }
|
2015-04-13 23:01:57 +02:00
|
|
|
>x : string, Symbol(x, Decl(plusOperatorWithStringType.ts, 22, 24))
|
2015-04-13 21:36:11 +02:00
|
|
|
>"" : string
|
2015-04-13 23:01:57 +02:00
|
|
|
>y : string, Symbol(y, Decl(plusOperatorWithStringType.ts, 22, 31))
|
2015-04-13 21:36:11 +02:00
|
|
|
>"" : string
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var ResultIsNumber5 = +{ x: "", y: (s: string) => { return s; } };
|
2015-04-13 23:01:57 +02:00
|
|
|
>ResultIsNumber5 : number, Symbol(ResultIsNumber5, Decl(plusOperatorWithStringType.ts, 23, 3))
|
2014-08-15 23:33:16 +02:00
|
|
|
>+{ x: "", y: (s: string) => { return s; } } : number
|
|
|
|
>{ x: "", y: (s: string) => { return s; } } : { x: string; y: (s: string) => string; }
|
2015-04-13 23:01:57 +02:00
|
|
|
>x : string, Symbol(x, Decl(plusOperatorWithStringType.ts, 23, 24))
|
2015-04-13 21:36:11 +02:00
|
|
|
>"" : string
|
2015-04-13 23:01:57 +02:00
|
|
|
>y : (s: string) => string, Symbol(y, Decl(plusOperatorWithStringType.ts, 23, 31))
|
2014-08-15 23:33:16 +02:00
|
|
|
>(s: string) => { return s; } : (s: string) => string
|
2015-04-13 23:01:57 +02:00
|
|
|
>s : string, Symbol(s, Decl(plusOperatorWithStringType.ts, 23, 36))
|
|
|
|
>s : string, Symbol(s, Decl(plusOperatorWithStringType.ts, 23, 36))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
// string type expressions
|
|
|
|
var ResultIsNumber6 = +objA.a;
|
2015-04-13 23:01:57 +02:00
|
|
|
>ResultIsNumber6 : number, Symbol(ResultIsNumber6, Decl(plusOperatorWithStringType.ts, 26, 3))
|
2014-08-15 23:33:16 +02:00
|
|
|
>+objA.a : number
|
2015-04-13 23:01:57 +02:00
|
|
|
>objA.a : string, Symbol(A.a, Decl(plusOperatorWithStringType.ts, 6, 9))
|
|
|
|
>objA : A, Symbol(objA, Decl(plusOperatorWithStringType.ts, 14, 3))
|
|
|
|
>a : string, Symbol(A.a, Decl(plusOperatorWithStringType.ts, 6, 9))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var ResultIsNumber7 = +M.n;
|
2015-04-13 23:01:57 +02:00
|
|
|
>ResultIsNumber7 : number, Symbol(ResultIsNumber7, Decl(plusOperatorWithStringType.ts, 27, 3))
|
2014-08-15 23:33:16 +02:00
|
|
|
>+M.n : number
|
2015-04-13 23:01:57 +02:00
|
|
|
>M.n : string, Symbol(M.n, Decl(plusOperatorWithStringType.ts, 11, 14))
|
|
|
|
>M : typeof M, Symbol(M, Decl(plusOperatorWithStringType.ts, 9, 1))
|
|
|
|
>n : string, Symbol(M.n, Decl(plusOperatorWithStringType.ts, 11, 14))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var ResultIsNumber8 = +STRING1[0];
|
2015-04-13 23:01:57 +02:00
|
|
|
>ResultIsNumber8 : number, Symbol(ResultIsNumber8, Decl(plusOperatorWithStringType.ts, 28, 3))
|
2014-08-15 23:33:16 +02:00
|
|
|
>+STRING1[0] : number
|
|
|
|
>STRING1[0] : string
|
2015-04-13 23:01:57 +02:00
|
|
|
>STRING1 : string[], Symbol(STRING1, Decl(plusOperatorWithStringType.ts, 2, 3))
|
2015-04-13 21:36:11 +02:00
|
|
|
>0 : number
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var ResultIsNumber9 = +foo();
|
2015-04-13 23:01:57 +02:00
|
|
|
>ResultIsNumber9 : number, Symbol(ResultIsNumber9, Decl(plusOperatorWithStringType.ts, 29, 3))
|
2014-08-15 23:33:16 +02:00
|
|
|
>+foo() : number
|
|
|
|
>foo() : string
|
2015-04-13 23:01:57 +02:00
|
|
|
>foo : () => string, Symbol(foo, Decl(plusOperatorWithStringType.ts, 2, 36))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var ResultIsNumber10 = +A.foo();
|
2015-04-13 23:01:57 +02:00
|
|
|
>ResultIsNumber10 : number, Symbol(ResultIsNumber10, Decl(plusOperatorWithStringType.ts, 30, 3))
|
2014-08-15 23:33:16 +02:00
|
|
|
>+A.foo() : number
|
|
|
|
>A.foo() : string
|
2015-04-13 23:01:57 +02:00
|
|
|
>A.foo : () => string, Symbol(A.foo, Decl(plusOperatorWithStringType.ts, 7, 21))
|
|
|
|
>A : typeof A, Symbol(A, Decl(plusOperatorWithStringType.ts, 4, 40))
|
|
|
|
>foo : () => string, Symbol(A.foo, Decl(plusOperatorWithStringType.ts, 7, 21))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var ResultIsNumber11 = +(STRING + STRING);
|
2015-04-13 23:01:57 +02:00
|
|
|
>ResultIsNumber11 : number, Symbol(ResultIsNumber11, Decl(plusOperatorWithStringType.ts, 31, 3))
|
2014-08-15 23:33:16 +02:00
|
|
|
>+(STRING + STRING) : number
|
|
|
|
>(STRING + STRING) : string
|
|
|
|
>STRING + STRING : string
|
2015-04-13 23:01:57 +02:00
|
|
|
>STRING : string, Symbol(STRING, Decl(plusOperatorWithStringType.ts, 1, 3))
|
|
|
|
>STRING : string, Symbol(STRING, Decl(plusOperatorWithStringType.ts, 1, 3))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var ResultIsNumber12 = +STRING.charAt(0);
|
2015-04-13 23:01:57 +02:00
|
|
|
>ResultIsNumber12 : number, Symbol(ResultIsNumber12, Decl(plusOperatorWithStringType.ts, 32, 3))
|
2014-08-15 23:33:16 +02:00
|
|
|
>+STRING.charAt(0) : number
|
|
|
|
>STRING.charAt(0) : string
|
2015-04-13 23:01:57 +02:00
|
|
|
>STRING.charAt : (pos: number) => string, Symbol(String.charAt, Decl(lib.d.ts, 279, 23))
|
|
|
|
>STRING : string, Symbol(STRING, Decl(plusOperatorWithStringType.ts, 1, 3))
|
|
|
|
>charAt : (pos: number) => string, Symbol(String.charAt, Decl(lib.d.ts, 279, 23))
|
2015-04-13 21:36:11 +02:00
|
|
|
>0 : number
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
// miss assignment operators
|
|
|
|
+"";
|
|
|
|
>+"" : number
|
2015-04-13 21:36:11 +02:00
|
|
|
>"" : string
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
+STRING;
|
|
|
|
>+STRING : number
|
2015-04-13 23:01:57 +02:00
|
|
|
>STRING : string, Symbol(STRING, Decl(plusOperatorWithStringType.ts, 1, 3))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
+STRING1;
|
|
|
|
>+STRING1 : number
|
2015-04-13 23:01:57 +02:00
|
|
|
>STRING1 : string[], Symbol(STRING1, Decl(plusOperatorWithStringType.ts, 2, 3))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
+foo();
|
|
|
|
>+foo() : number
|
|
|
|
>foo() : string
|
2015-04-13 23:01:57 +02:00
|
|
|
>foo : () => string, Symbol(foo, Decl(plusOperatorWithStringType.ts, 2, 36))
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
+objA.a,M.n;
|
|
|
|
>+objA.a,M.n : string
|
|
|
|
>+objA.a : number
|
2015-04-13 23:01:57 +02:00
|
|
|
>objA.a : string, Symbol(A.a, Decl(plusOperatorWithStringType.ts, 6, 9))
|
|
|
|
>objA : A, Symbol(objA, Decl(plusOperatorWithStringType.ts, 14, 3))
|
|
|
|
>a : string, Symbol(A.a, Decl(plusOperatorWithStringType.ts, 6, 9))
|
|
|
|
>M.n : string, Symbol(M.n, Decl(plusOperatorWithStringType.ts, 11, 14))
|
|
|
|
>M : typeof M, Symbol(M, Decl(plusOperatorWithStringType.ts, 9, 1))
|
|
|
|
>n : string, Symbol(M.n, Decl(plusOperatorWithStringType.ts, 11, 14))
|
2014-08-15 23:33:16 +02:00
|
|
|
|