38 lines
577 B
Text
38 lines
577 B
Text
|
=== tests/cases/compiler/unaryPlus.ts ===
|
||
|
// allowed per spec
|
||
|
var a = +1;
|
||
|
>a : number
|
||
|
>+1 : number
|
||
|
|
||
|
var b = +(<any>"");
|
||
|
>b : number
|
||
|
>+(<any>"") : number
|
||
|
>(<any>"") : any
|
||
|
><any>"" : any
|
||
|
|
||
|
enum E { some, thing };
|
||
|
>E : E
|
||
|
>some : E
|
||
|
>thing : E
|
||
|
|
||
|
var c = +E.some;
|
||
|
>c : number
|
||
|
>+E.some : number
|
||
|
>E.some : E
|
||
|
>E : typeof E
|
||
|
>some : E
|
||
|
|
||
|
// also allowed, used to be errors
|
||
|
var x = +"3"; //should be valid
|
||
|
>x : number
|
||
|
>+"3" : number
|
||
|
|
||
|
var y = -"3"; // should be valid
|
||
|
>y : number
|
||
|
>-"3" : number
|
||
|
|
||
|
var z = ~"3"; // should be valid
|
||
|
>z : number
|
||
|
>~"3" : number
|
||
|
|