This commit is contained in:
Anders Hejlsberg 2016-08-26 15:52:15 -07:00
Родитель 8c2f1e18ff
Коммит 4e2e7602e2
30 изменённых файлов: 1850 добавлений и 22 удалений

Просмотреть файл

@ -5,7 +5,7 @@ enum TokenType { One, Two };
>Two : TokenType
var list = {};
>list : {}
>list : any
>{} : {}
@ -26,7 +26,7 @@ function foo() {
>x : TokenType
>TokenType : TokenType
>list['one'] : any
>list : {}
>list : any
>'one' : string
}

Просмотреть файл

@ -12,7 +12,7 @@ interface Function {
>functionData : string
}
var o = {};
>o : {}
>o : any
>{} : {}
var f = function () { };

Просмотреть файл

@ -16,7 +16,7 @@ var r = foo({});
>{} : {}
var a = {};
>a : {}
>a : any
>{} : {}
var r = foo({});
@ -68,7 +68,7 @@ var r = foo2({});
>{} : {}
var a = {};
>a : {}
>a : any
>{} : {}
var r = foo2({});

Просмотреть файл

@ -374,17 +374,17 @@ do { }while(i)
>i : number[]
var j = {};
>j : {}
>j : any
>{} : {}
if (j) { }
>j : {}
>j : any
while (j) { }
>j : {}
>j : any
do { }while(j)
>j : {}
>j : any
var k = { x: 1, y: 'a' };
>k : { x: number; y: string; }

Просмотреть файл

@ -0,0 +1,33 @@
=== tests/cases/compiler/assignmentCompatForEnums.ts ===
enum TokenType { One, Two };
>TokenType : TokenType
>One : TokenType
>Two : TokenType
var list = {};
>list : any
>{} : {}
function returnType(): TokenType { return null; }
>returnType : () => TokenType
>TokenType : TokenType
>null : null
function foo() {
>foo : () => void
var x = returnType();
>x : TokenType
>returnType() : TokenType
>returnType : () => TokenType
var x: TokenType = list['one'];
>x : TokenType
>TokenType : TokenType
>list['one'] : any
>list : any
>'one' : string
}

Просмотреть файл

@ -0,0 +1,45 @@
=== tests/cases/compiler/augmentedTypeBracketNamedPropertyAccess.ts ===
interface Object {
>Object : Object
data: number;
>data : number
}
interface Function {
>Function : Function
functionData: string;
>functionData : string
}
var o = {};
>o : any
>{} : {}
var f = function () { };
>f : () => void
>function () { } : () => void
var r1 = o['data']; // Should be number
>r1 : number
>o['data'] : number
>o : {}
>'data' : string
var r2 = o['functionData']; // Should be any (no property found)
>r2 : any
>o['functionData'] : any
>o : {}
>'functionData' : string
var r3 = f['functionData']; // Should be string
>r3 : string
>f['functionData'] : string
>f : () => void
>'functionData' : string
var r4 = f['data']; // Should be number
>r4 : number
>f['data'] : number
>f : () => void
>'data' : string

Просмотреть файл

@ -0,0 +1,107 @@
=== tests/cases/conformance/types/typeParameters/typeArgumentLists/constraintSatisfactionWithEmptyObject.ts ===
// valid uses of a basic object constraint, no errors expected
// Object constraint
function foo<T extends Object>(x: T) { }
>foo : <T extends Object>(x: T) => void
>T : T
>Object : Object
>x : T
>T : T
var r = foo({});
>r : void
>foo({}) : void
>foo : <T extends Object>(x: T) => void
>{} : {}
var a = {};
>a : any
>{} : {}
var r = foo({});
>r : void
>foo({}) : void
>foo : <T extends Object>(x: T) => void
>{} : {}
class C<T extends Object> {
>C : C<T>
>T : T
>Object : Object
constructor(public x: T) { }
>x : T
>T : T
}
var r2 = new C({});
>r2 : C<{}>
>new C({}) : C<{}>
>C : typeof C
>{} : {}
interface I<T extends Object> {
>I : I<T>
>T : T
>Object : Object
x: T;
>x : T
>T : T
}
var i: I<{}>;
>i : I<{}>
>I : I<T>
// {} constraint
function foo2<T extends {}>(x: T) { }
>foo2 : <T extends {}>(x: T) => void
>T : T
>x : T
>T : T
var r = foo2({});
>r : void
>foo2({}) : void
>foo2 : <T extends {}>(x: T) => void
>{} : {}
var a = {};
>a : any
>{} : {}
var r = foo2({});
>r : void
>foo2({}) : void
>foo2 : <T extends {}>(x: T) => void
>{} : {}
class C2<T extends {}> {
>C2 : C2<T>
>T : T
constructor(public x: T) { }
>x : T
>T : T
}
var r2 = new C2({});
>r2 : C<{}>
>new C2({}) : C2<{}>
>C2 : typeof C2
>{} : {}
interface I2<T extends {}> {
>I2 : I2<T>
>T : T
x: T;
>x : T
>T : T
}
var i2: I2<{}>;
>i2 : I2<{}>
>I2 : I2<T>

Просмотреть файл

@ -0,0 +1,434 @@
=== tests/cases/conformance/statements/ifDoWhileStatements/ifDoWhileStatements.ts ===
interface I {
>I : I
id: number;
>id : number
}
class C implements I {
>C : C
>I : I
id: number;
>id : number
name: string;
>name : string
}
class C2 extends C {
>C2 : C2
>C : C
valid: boolean;
>valid : boolean
}
class D<T>{
>D : D<T>
>T : T
source: T;
>source : T
>T : T
recurse: D<T>;
>recurse : D<T>
>D : D<T>
>T : T
wrapped: D<D<T>>
>wrapped : D<D<T>>
>D : D<T>
>D : D<T>
>T : T
}
function F(x: string): number { return 42; }
>F : (x: string) => number
>x : string
>42 : number
function F2(x: number): boolean { return x < 42; }
>F2 : (x: number) => boolean
>x : number
>x < 42 : boolean
>x : number
>42 : number
module M {
>M : typeof M
export class A {
>A : A
name: string;
>name : string
}
export function F2(x: number): string { return x.toString(); }
>F2 : (x: number) => string
>x : number
>x.toString() : string
>x.toString : (radix?: number) => string
>x : number
>toString : (radix?: number) => string
}
module N {
>N : typeof N
export class A {
>A : A
id: number;
>id : number
}
export function F2(x: number): string { return x.toString(); }
>F2 : (x: number) => string
>x : number
>x.toString() : string
>x.toString : (radix?: number) => string
>x : number
>toString : (radix?: number) => string
}
// literals
if (true) { }
>true : boolean
while (true) { }
>true : boolean
do { }while(true)
>true : boolean
if (null) { }
>null : null
while (null) { }
>null : null
do { }while(null)
>null : null
if (undefined) { }
>undefined : undefined
while (undefined) { }
>undefined : undefined
do { }while(undefined)
>undefined : undefined
if (0.0) { }
>0.0 : number
while (0.0) { }
>0.0 : number
do { }while(0.0)
>0.0 : number
if ('a string') { }
>'a string' : string
while ('a string') { }
>'a string' : string
do { }while('a string')
>'a string' : string
if ('') { }
>'' : string
while ('') { }
>'' : string
do { }while('')
>'' : string
if (/[a-z]/) { }
>/[a-z]/ : RegExp
while (/[a-z]/) { }
>/[a-z]/ : RegExp
do { }while(/[a-z]/)
>/[a-z]/ : RegExp
if ([]) { }
>[] : undefined[]
while ([]) { }
>[] : undefined[]
do { }while([])
>[] : undefined[]
if ([1, 2]) { }
>[1, 2] : number[]
>1 : number
>2 : number
while ([1, 2]) { }
>[1, 2] : number[]
>1 : number
>2 : number
do { }while([1, 2])
>[1, 2] : number[]
>1 : number
>2 : number
if ({}) { }
>{} : {}
while ({}) { }
>{} : {}
do { }while({})
>{} : {}
if ({ x: 1, y: 'a' }) { }
>{ x: 1, y: 'a' } : { x: number; y: string; }
>x : number
>1 : number
>y : string
>'a' : string
while ({ x: 1, y: 'a' }) { }
>{ x: 1, y: 'a' } : { x: number; y: string; }
>x : number
>1 : number
>y : string
>'a' : string
do { }while({ x: 1, y: 'a' })
>{ x: 1, y: 'a' } : { x: number; y: string; }
>x : number
>1 : number
>y : string
>'a' : string
if (() => 43) { }
>() => 43 : () => number
>43 : number
while (() => 43) { }
>() => 43 : () => number
>43 : number
do { }while(() => 43)
>() => 43 : () => number
>43 : number
if (new C()) { }
>new C() : C
>C : typeof C
while (new C()) { }
>new C() : C
>C : typeof C
do { }while(new C())
>new C() : C
>C : typeof C
if (new D<C>()) { }
>new D<C>() : D<C>
>D : typeof D
>C : C
while (new D<C>()) { }
>new D<C>() : D<C>
>D : typeof D
>C : C
do { }while(new D<C>())
>new D<C>() : D<C>
>D : typeof D
>C : C
// references
var a = true;
>a : boolean
>true : boolean
if (a) { }
>a : boolean
while (a) { }
>a : boolean
do { }while(a)
>a : boolean
var b = null;
>b : any
>null : null
if (b) { }
>b : any
while (b) { }
>b : any
do { }while(b)
>b : any
var c = undefined;
>c : any
>undefined : undefined
if (c) { }
>c : any
while (c) { }
>c : any
do { }while(c)
>c : any
var d = 0.0;
>d : number
>0.0 : number
if (d) { }
>d : number
while (d) { }
>d : number
do { }while(d)
>d : number
var e = 'a string';
>e : string
>'a string' : string
if (e) { }
>e : string
while (e) { }
>e : string
do { }while(e)
>e : string
var f = '';
>f : string
>'' : string
if (f) { }
>f : string
while (f) { }
>f : string
do { }while(f)
>f : string
var g = /[a-z]/
>g : RegExp
>/[a-z]/ : RegExp
if (g) { }
>g : RegExp
while (g) { }
>g : RegExp
do { }while(g)
>g : RegExp
var h = [];
>h : any[]
>[] : undefined[]
if (h) { }
>h : any[]
while (h) { }
>h : any[]
do { }while(h)
>h : any[]
var i = [1, 2];
>i : number[]
>[1, 2] : number[]
>1 : number
>2 : number
if (i) { }
>i : number[]
while (i) { }
>i : number[]
do { }while(i)
>i : number[]
var j = {};
>j : any
>{} : {}
if (j) { }
>j : any
while (j) { }
>j : any
do { }while(j)
>j : any
var k = { x: 1, y: 'a' };
>k : { x: number; y: string; }
>{ x: 1, y: 'a' } : { x: number; y: string; }
>x : number
>1 : number
>y : string
>'a' : string
if (k) { }
>k : { x: number; y: string; }
while (k) { }
>k : { x: number; y: string; }
do { }while(k)
>k : { x: number; y: string; }
function fn(x?: string): I { return null; }
>fn : (x?: string) => I
>x : string
>I : I
>null : null
if (fn()) { }
>fn() : I
>fn : (x?: string) => I
while (fn()) { }
>fn() : I
>fn : (x?: string) => I
do { }while(fn())
>fn() : I
>fn : (x?: string) => I
if (fn) { }
>fn : (x?: string) => I
while (fn) { }
>fn : (x?: string) => I
do { }while(fn)
>fn : (x?: string) => I

Просмотреть файл

@ -0,0 +1,231 @@
=== tests/cases/compiler/modularizeLibrary_NoErrorDuplicateLibOptions1.ts ===
// Using Es6 array
function f(x: number, y: number, z: number) {
>f : (x: number, y: number, z: number) => any[]
>x : number
>y : number
>z : number
return Array.from(arguments);
>Array.from(arguments) : any[]
>Array.from : { <T, U>(iterable: Iterable<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(iterable: Iterable<T>): T[]; <T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(arrayLike: ArrayLike<T>): T[]; }
>Array : ArrayConstructor
>from : { <T, U>(iterable: Iterable<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(iterable: Iterable<T>): T[]; <T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(arrayLike: ArrayLike<T>): T[]; }
>arguments : IArguments
}
f(1, 2, 3); // no error
>f(1, 2, 3) : any[]
>f : (x: number, y: number, z: number) => any[]
>1 : number
>2 : number
>3 : number
// Using ES6 collection
var m = new Map<string, number>();
>m : Map<string, number>
>new Map<string, number>() : Map<string, number>
>Map : MapConstructor
m.clear();
>m.clear() : void
>m.clear : () => void
>m : Map<string, number>
>clear : () => void
// Using ES6 iterable
m.keys();
>m.keys() : IterableIterator<string>
>m.keys : () => IterableIterator<string>
>m : Map<string, number>
>keys : () => IterableIterator<string>
// Using ES6 function
function Baz() { }
>Baz : () => void
Baz.name;
>Baz.name : string
>Baz : () => void
>name : string
// Using ES6 generator
function* gen() {
>gen : () => IterableIterator<number>
let i = 0;
>i : number
>0 : number
while (i < 10) {
>i < 10 : boolean
>i : number
>10 : number
yield i;
>yield i : any
>i : number
i++;
>i++ : number
>i : number
}
}
function* gen2() {
>gen2 : () => IterableIterator<number>
let i = 0;
>i : number
>0 : number
while (i < 10) {
>i < 10 : boolean
>i : number
>10 : number
yield i;
>yield i : any
>i : number
i++;
>i++ : number
>i : number
}
}
// Using ES6 math
Math.sign(1);
>Math.sign(1) : number
>Math.sign : (x: number) => number
>Math : Math
>sign : (x: number) => number
>1 : number
// Using ES6 object
var o = {
>o : { a: number; [Symbol.hasInstance](value: any): boolean; }
>{ a: 2, [Symbol.hasInstance](value: any) { return false; }} : { a: number; [Symbol.hasInstance](value: any): boolean; }
a: 2,
>a : number
>2 : number
[Symbol.hasInstance](value: any) {
>Symbol.hasInstance : symbol
>Symbol : SymbolConstructor
>hasInstance : symbol
>value : any
return false;
>false : boolean
}
};
o.hasOwnProperty(Symbol.hasInstance);
>o.hasOwnProperty(Symbol.hasInstance) : boolean
>o.hasOwnProperty : { (v: PropertyKey): boolean; (v: string): boolean; }
>o : { a: number; [Symbol.hasInstance](value: any): boolean; }
>hasOwnProperty : { (v: PropertyKey): boolean; (v: string): boolean; }
>Symbol.hasInstance : symbol
>Symbol : SymbolConstructor
>hasInstance : symbol
// Using ES6 promise
async function out() {
>out : () => Promise<{}>
return new Promise(function (resolve, reject) {});
>new Promise(function (resolve, reject) {}) : Promise<{}>
>Promise : PromiseConstructor
>function (resolve, reject) {} : (resolve: (value?: {} | PromiseLike<{}>) => void, reject: (reason?: any) => void) => void
>resolve : (value?: {} | PromiseLike<{}>) => void
>reject : (reason?: any) => void
}
declare var console: any;
>console : any
out().then(() => {
>out().then(() => { console.log("Yea!");}) : Promise<void>
>out().then : { <TResult1, TResult2>(onfulfilled: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<{}>; }
>out() : Promise<{}>
>out : () => Promise<{}>
>then : { <TResult1, TResult2>(onfulfilled: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<{}>; }
>() => { console.log("Yea!");} : () => void
console.log("Yea!");
>console.log("Yea!") : any
>console.log : any
>console : any
>log : any
>"Yea!" : string
});
// Using Es6 proxy
var t = {}
>t : any
>{} : {}
var p = new Proxy(t, {});
>p : {}
>new Proxy(t, {}) : {}
>Proxy : ProxyConstructor
>t : {}
>{} : {}
// Using ES6 reflect
Reflect.isExtensible({});
>Reflect.isExtensible({}) : boolean
>Reflect.isExtensible : (target: any) => boolean
>Reflect : typeof Reflect
>isExtensible : (target: any) => boolean
>{} : {}
// Using Es6 regexp
var reg = new RegExp("/s");
>reg : RegExp
>new RegExp("/s") : RegExp
>RegExp : RegExpConstructor
>"/s" : string
reg.flags;
>reg.flags : string
>reg : RegExp
>flags : string
// Using ES6 string
var str = "Hello world";
>str : string
>"Hello world" : string
str.includes("hello", 0);
>str.includes("hello", 0) : boolean
>str.includes : (searchString: string, position?: number) => boolean
>str : string
>includes : (searchString: string, position?: number) => boolean
>"hello" : string
>0 : number
// Using ES6 symbol
var s = Symbol();
>s : symbol
>Symbol() : symbol
>Symbol : SymbolConstructor
// Using ES6 wellknown-symbol
const o1 = {
>o1 : { [Symbol.hasInstance](value: any): boolean; }
>{ [Symbol.hasInstance](value: any) { return false; }} : { [Symbol.hasInstance](value: any): boolean; }
[Symbol.hasInstance](value: any) {
>Symbol.hasInstance : symbol
>Symbol : SymbolConstructor
>hasInstance : symbol
>value : any
return false;
>false : boolean
}
}

Просмотреть файл

@ -0,0 +1,231 @@
=== tests/cases/compiler/modularizeLibrary_NoErrorDuplicateLibOptions2.ts ===
// Using Es6 array
function f(x: number, y: number, z: number) {
>f : (x: number, y: number, z: number) => any[]
>x : number
>y : number
>z : number
return Array.from(arguments);
>Array.from(arguments) : any[]
>Array.from : { <T, U>(iterable: Iterable<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(iterable: Iterable<T>): T[]; <T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(arrayLike: ArrayLike<T>): T[]; }
>Array : ArrayConstructor
>from : { <T, U>(iterable: Iterable<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(iterable: Iterable<T>): T[]; <T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(arrayLike: ArrayLike<T>): T[]; }
>arguments : IArguments
}
f(1, 2, 3); // no error
>f(1, 2, 3) : any[]
>f : (x: number, y: number, z: number) => any[]
>1 : number
>2 : number
>3 : number
// Using ES6 collection
var m = new Map<string, number>();
>m : Map<string, number>
>new Map<string, number>() : Map<string, number>
>Map : MapConstructor
m.clear();
>m.clear() : void
>m.clear : () => void
>m : Map<string, number>
>clear : () => void
// Using ES6 iterable
m.keys();
>m.keys() : IterableIterator<string>
>m.keys : () => IterableIterator<string>
>m : Map<string, number>
>keys : () => IterableIterator<string>
// Using ES6 function
function Baz() { }
>Baz : () => void
Baz.name;
>Baz.name : string
>Baz : () => void
>name : string
// Using ES6 generator
function* gen() {
>gen : () => IterableIterator<number>
let i = 0;
>i : number
>0 : number
while (i < 10) {
>i < 10 : boolean
>i : number
>10 : number
yield i;
>yield i : any
>i : number
i++;
>i++ : number
>i : number
}
}
function* gen2() {
>gen2 : () => IterableIterator<number>
let i = 0;
>i : number
>0 : number
while (i < 10) {
>i < 10 : boolean
>i : number
>10 : number
yield i;
>yield i : any
>i : number
i++;
>i++ : number
>i : number
}
}
// Using ES6 math
Math.sign(1);
>Math.sign(1) : number
>Math.sign : (x: number) => number
>Math : Math
>sign : (x: number) => number
>1 : number
// Using ES6 object
var o = {
>o : { a: number; [Symbol.hasInstance](value: any): boolean; }
>{ a: 2, [Symbol.hasInstance](value: any) { return false; }} : { a: number; [Symbol.hasInstance](value: any): boolean; }
a: 2,
>a : number
>2 : number
[Symbol.hasInstance](value: any) {
>Symbol.hasInstance : symbol
>Symbol : SymbolConstructor
>hasInstance : symbol
>value : any
return false;
>false : boolean
}
};
o.hasOwnProperty(Symbol.hasInstance);
>o.hasOwnProperty(Symbol.hasInstance) : boolean
>o.hasOwnProperty : { (v: PropertyKey): boolean; (v: string): boolean; }
>o : { a: number; [Symbol.hasInstance](value: any): boolean; }
>hasOwnProperty : { (v: PropertyKey): boolean; (v: string): boolean; }
>Symbol.hasInstance : symbol
>Symbol : SymbolConstructor
>hasInstance : symbol
// Using ES6 promise
async function out() {
>out : () => Promise<{}>
return new Promise(function (resolve, reject) {});
>new Promise(function (resolve, reject) {}) : Promise<{}>
>Promise : PromiseConstructor
>function (resolve, reject) {} : (resolve: (value?: {} | PromiseLike<{}>) => void, reject: (reason?: any) => void) => void
>resolve : (value?: {} | PromiseLike<{}>) => void
>reject : (reason?: any) => void
}
declare var console: any;
>console : any
out().then(() => {
>out().then(() => { console.log("Yea!");}) : Promise<void>
>out().then : { <TResult1, TResult2>(onfulfilled: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<{}>; }
>out() : Promise<{}>
>out : () => Promise<{}>
>then : { <TResult1, TResult2>(onfulfilled: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<{}>; }
>() => { console.log("Yea!");} : () => void
console.log("Yea!");
>console.log("Yea!") : any
>console.log : any
>console : any
>log : any
>"Yea!" : string
});
// Using Es6 proxy
var t = {}
>t : any
>{} : {}
var p = new Proxy(t, {});
>p : {}
>new Proxy(t, {}) : {}
>Proxy : ProxyConstructor
>t : {}
>{} : {}
// Using ES6 reflect
Reflect.isExtensible({});
>Reflect.isExtensible({}) : boolean
>Reflect.isExtensible : (target: any) => boolean
>Reflect : typeof Reflect
>isExtensible : (target: any) => boolean
>{} : {}
// Using Es6 regexp
var reg = new RegExp("/s");
>reg : RegExp
>new RegExp("/s") : RegExp
>RegExp : RegExpConstructor
>"/s" : string
reg.flags;
>reg.flags : string
>reg : RegExp
>flags : string
// Using ES6 string
var str = "Hello world";
>str : string
>"Hello world" : string
str.includes("hello", 0);
>str.includes("hello", 0) : boolean
>str.includes : (searchString: string, position?: number) => boolean
>str : string
>includes : (searchString: string, position?: number) => boolean
>"hello" : string
>0 : number
// Using ES6 symbol
var s = Symbol();
>s : symbol
>Symbol() : symbol
>Symbol : SymbolConstructor
// Using ES6 wellknown-symbol
const o1 = {
>o1 : { [Symbol.hasInstance](value: any): boolean; }
>{ [Symbol.hasInstance](value: any) { return false; }} : { [Symbol.hasInstance](value: any): boolean; }
[Symbol.hasInstance](value: any) {
>Symbol.hasInstance : symbol
>Symbol : SymbolConstructor
>hasInstance : symbol
>value : any
return false;
>false : boolean
}
}

Просмотреть файл

@ -0,0 +1,231 @@
=== tests/cases/compiler/modularizeLibrary_TargetES5UsingES6Lib.ts ===
// Using Es6 array
function f(x: number, y: number, z: number) {
>f : (x: number, y: number, z: number) => any[]
>x : number
>y : number
>z : number
return Array.from(arguments);
>Array.from(arguments) : any[]
>Array.from : { <T, U>(iterable: Iterable<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(iterable: Iterable<T>): T[]; <T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(arrayLike: ArrayLike<T>): T[]; }
>Array : ArrayConstructor
>from : { <T, U>(iterable: Iterable<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(iterable: Iterable<T>): T[]; <T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(arrayLike: ArrayLike<T>): T[]; }
>arguments : IArguments
}
f(1, 2, 3); // no error
>f(1, 2, 3) : any[]
>f : (x: number, y: number, z: number) => any[]
>1 : number
>2 : number
>3 : number
// Using ES6 collection
var m = new Map<string, number>();
>m : Map<string, number>
>new Map<string, number>() : Map<string, number>
>Map : MapConstructor
m.clear();
>m.clear() : void
>m.clear : () => void
>m : Map<string, number>
>clear : () => void
// Using ES6 iterable
m.keys();
>m.keys() : IterableIterator<string>
>m.keys : () => IterableIterator<string>
>m : Map<string, number>
>keys : () => IterableIterator<string>
// Using ES6 function
function Baz() { }
>Baz : () => void
Baz.name;
>Baz.name : string
>Baz : () => void
>name : string
// Using ES6 generator
function* gen() {
>gen : () => IterableIterator<number>
let i = 0;
>i : number
>0 : number
while (i < 10) {
>i < 10 : boolean
>i : number
>10 : number
yield i;
>yield i : any
>i : number
i++;
>i++ : number
>i : number
}
}
function* gen2() {
>gen2 : () => IterableIterator<number>
let i = 0;
>i : number
>0 : number
while (i < 10) {
>i < 10 : boolean
>i : number
>10 : number
yield i;
>yield i : any
>i : number
i++;
>i++ : number
>i : number
}
}
// Using ES6 math
Math.sign(1);
>Math.sign(1) : number
>Math.sign : (x: number) => number
>Math : Math
>sign : (x: number) => number
>1 : number
// Using ES6 object
var o = {
>o : { a: number; [Symbol.hasInstance](value: any): boolean; }
>{ a: 2, [Symbol.hasInstance](value: any) { return false; }} : { a: number; [Symbol.hasInstance](value: any): boolean; }
a: 2,
>a : number
>2 : number
[Symbol.hasInstance](value: any) {
>Symbol.hasInstance : symbol
>Symbol : SymbolConstructor
>hasInstance : symbol
>value : any
return false;
>false : boolean
}
};
o.hasOwnProperty(Symbol.hasInstance);
>o.hasOwnProperty(Symbol.hasInstance) : boolean
>o.hasOwnProperty : { (v: PropertyKey): boolean; (v: string): boolean; }
>o : { a: number; [Symbol.hasInstance](value: any): boolean; }
>hasOwnProperty : { (v: PropertyKey): boolean; (v: string): boolean; }
>Symbol.hasInstance : symbol
>Symbol : SymbolConstructor
>hasInstance : symbol
// Using ES6 promise
async function out() {
>out : () => Promise<{}>
return new Promise(function (resolve, reject) {});
>new Promise(function (resolve, reject) {}) : Promise<{}>
>Promise : PromiseConstructor
>function (resolve, reject) {} : (resolve: (value?: {} | PromiseLike<{}>) => void, reject: (reason?: any) => void) => void
>resolve : (value?: {} | PromiseLike<{}>) => void
>reject : (reason?: any) => void
}
declare var console: any;
>console : any
out().then(() => {
>out().then(() => { console.log("Yea!");}) : Promise<void>
>out().then : { <TResult1, TResult2>(onfulfilled: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<{}>; }
>out() : Promise<{}>
>out : () => Promise<{}>
>then : { <TResult1, TResult2>(onfulfilled: (value: {}) => TResult1 | PromiseLike<TResult1>, onrejected: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>, onrejected: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>; <TResult>(onfulfilled: (value: {}) => TResult | PromiseLike<TResult>): Promise<TResult>; (): Promise<{}>; }
>() => { console.log("Yea!");} : () => void
console.log("Yea!");
>console.log("Yea!") : any
>console.log : any
>console : any
>log : any
>"Yea!" : string
});
// Using Es6 proxy
var t = {}
>t : any
>{} : {}
var p = new Proxy(t, {});
>p : {}
>new Proxy(t, {}) : {}
>Proxy : ProxyConstructor
>t : {}
>{} : {}
// Using ES6 reflect
Reflect.isExtensible({});
>Reflect.isExtensible({}) : boolean
>Reflect.isExtensible : (target: any) => boolean
>Reflect : typeof Reflect
>isExtensible : (target: any) => boolean
>{} : {}
// Using Es6 regexp
var reg = new RegExp("/s");
>reg : RegExp
>new RegExp("/s") : RegExp
>RegExp : RegExpConstructor
>"/s" : string
reg.flags;
>reg.flags : string
>reg : RegExp
>flags : string
// Using ES6 string
var str = "Hello world";
>str : string
>"Hello world" : string
str.includes("hello", 0);
>str.includes("hello", 0) : boolean
>str.includes : (searchString: string, position?: number) => boolean
>str : string
>includes : (searchString: string, position?: number) => boolean
>"hello" : string
>0 : number
// Using ES6 symbol
var s = Symbol();
>s : symbol
>Symbol() : symbol
>Symbol : SymbolConstructor
// Using ES6 wellknown-symbol
const o1 = {
>o1 : { [Symbol.hasInstance](value: any): boolean; }
>{ [Symbol.hasInstance](value: any) { return false; }} : { [Symbol.hasInstance](value: any): boolean; }
[Symbol.hasInstance](value: any) {
>Symbol.hasInstance : symbol
>Symbol : SymbolConstructor
>hasInstance : symbol
>value : any
return false;
>false : boolean
}
}

Просмотреть файл

@ -0,0 +1,154 @@
=== tests/cases/compiler/modularizeLibrary_TargetES6UsingES6Lib.ts ===
// Using Es6 array
function f(x: number, y: number, z: number) {
>f : (x: number, y: number, z: number) => any[]
>x : number
>y : number
>z : number
return Array.from(arguments);
>Array.from(arguments) : any[]
>Array.from : { <T, U>(iterable: Iterable<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(iterable: Iterable<T>): T[]; <T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(arrayLike: ArrayLike<T>): T[]; }
>Array : ArrayConstructor
>from : { <T, U>(iterable: Iterable<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(iterable: Iterable<T>): T[]; <T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; <T>(arrayLike: ArrayLike<T>): T[]; }
>arguments : IArguments
}
f(1, 2, 3); // no error
>f(1, 2, 3) : any[]
>f : (x: number, y: number, z: number) => any[]
>1 : number
>2 : number
>3 : number
// Using ES6 collection
var m = new Map<string, number>();
>m : Map<string, number>
>new Map<string, number>() : Map<string, number>
>Map : MapConstructor
m.clear();
>m.clear() : void
>m.clear : () => void
>m : Map<string, number>
>clear : () => void
// Using ES6 iterable
m.keys();
>m.keys() : IterableIterator<string>
>m.keys : () => IterableIterator<string>
>m : Map<string, number>
>keys : () => IterableIterator<string>
// Using ES6 function
function Baz() { }
>Baz : () => void
Baz.name;
>Baz.name : string
>Baz : () => void
>name : string
// Using ES6 math
Math.sign(1);
>Math.sign(1) : number
>Math.sign : (x: number) => number
>Math : Math
>sign : (x: number) => number
>1 : number
// Using ES6 object
var o = {
>o : { a: number; [Symbol.hasInstance](value: any): boolean; }
>{ a: 2, [Symbol.hasInstance](value: any) { return false; }} : { a: number; [Symbol.hasInstance](value: any): boolean; }
a: 2,
>a : number
>2 : number
[Symbol.hasInstance](value: any) {
>Symbol.hasInstance : symbol
>Symbol : SymbolConstructor
>hasInstance : symbol
>value : any
return false;
>false : boolean
}
};
o.hasOwnProperty(Symbol.hasInstance);
>o.hasOwnProperty(Symbol.hasInstance) : boolean
>o.hasOwnProperty : { (v: string): boolean; (v: PropertyKey): boolean; }
>o : { a: number; [Symbol.hasInstance](value: any): boolean; }
>hasOwnProperty : { (v: string): boolean; (v: PropertyKey): boolean; }
>Symbol.hasInstance : symbol
>Symbol : SymbolConstructor
>hasInstance : symbol
// Using Es6 proxy
var t = {}
>t : any
>{} : {}
var p = new Proxy(t, {});
>p : {}
>new Proxy(t, {}) : {}
>Proxy : ProxyConstructor
>t : {}
>{} : {}
// Using ES6 reflect
Reflect.isExtensible({});
>Reflect.isExtensible({}) : boolean
>Reflect.isExtensible : (target: any) => boolean
>Reflect : typeof Reflect
>isExtensible : (target: any) => boolean
>{} : {}
// Using Es6 regexp
var reg = new RegExp("/s");
>reg : RegExp
>new RegExp("/s") : RegExp
>RegExp : RegExpConstructor
>"/s" : string
reg.flags;
>reg.flags : string
>reg : RegExp
>flags : string
// Using ES6 string
var str = "Hello world";
>str : string
>"Hello world" : string
str.includes("hello", 0);
>str.includes("hello", 0) : boolean
>str.includes : (searchString: string, position?: number) => boolean
>str : string
>includes : (searchString: string, position?: number) => boolean
>"hello" : string
>0 : number
// Using ES6 symbol
var s = Symbol();
>s : symbol
>Symbol() : symbol
>Symbol : SymbolConstructor
// Using ES6 wellknown-symbol
const o1 = {
>o1 : { [Symbol.hasInstance](value: any): boolean; }
>{ [Symbol.hasInstance](value: any) { return false; }} : { [Symbol.hasInstance](value: any): boolean; }
[Symbol.hasInstance](value: any) {
>Symbol.hasInstance : symbol
>Symbol : SymbolConstructor
>hasInstance : symbol
>value : any
return false;
>false : boolean
}
}

Просмотреть файл

@ -0,0 +1,45 @@
=== tests/cases/compiler/modularizeLibrary_UsingES5LibAndES6FeatureLibs.ts ===
var s = Symbol();
>s : symbol
>Symbol() : symbol
>Symbol : SymbolConstructor
var t = {};
>t : any
>{} : {}
var p = new Proxy(t, {});
>p : {}
>new Proxy(t, {}) : {}
>Proxy : ProxyConstructor
>t : {}
>{} : {}
Reflect.ownKeys({});
>Reflect.ownKeys({}) : PropertyKey[]
>Reflect.ownKeys : (target: any) => PropertyKey[]
>Reflect : typeof Reflect
>ownKeys : (target: any) => PropertyKey[]
>{} : {}
function* idGen() {
>idGen : () => IterableIterator<number>
let i = 10;
>i : number
>10 : number
while (i < 20) {
>i < 20 : boolean
>i : number
>20 : number
yield i + 2;
>yield i + 2 : any
>i + 2 : number
>i : number
>2 : number
}
}

Просмотреть файл

@ -0,0 +1,130 @@
=== tests/cases/compiler/noImplicitAnyIndexingSuppressed.ts ===
enum MyEmusEnum {
>MyEmusEnum : MyEmusEnum
emu
>emu : MyEmusEnum
}
// Should be okay; should be a string.
var strRepresentation1 = MyEmusEnum[0]
>strRepresentation1 : string
>MyEmusEnum[0] : string
>MyEmusEnum : typeof MyEmusEnum
>0 : number
// Should be okay; should be a string.
var strRepresentation2 = MyEmusEnum[MyEmusEnum.emu]
>strRepresentation2 : string
>MyEmusEnum[MyEmusEnum.emu] : string
>MyEmusEnum : typeof MyEmusEnum
>MyEmusEnum.emu : MyEmusEnum
>MyEmusEnum : typeof MyEmusEnum
>emu : MyEmusEnum
// Should be okay, as we suppress implicit 'any' property access checks
var strRepresentation3 = MyEmusEnum["monehh"];
>strRepresentation3 : any
>MyEmusEnum["monehh"] : any
>MyEmusEnum : typeof MyEmusEnum
>"monehh" : string
// Should be okay; should be a MyEmusEnum
var strRepresentation4 = MyEmusEnum["emu"];
>strRepresentation4 : MyEmusEnum
>MyEmusEnum["emu"] : MyEmusEnum
>MyEmusEnum : typeof MyEmusEnum
>"emu" : string
// Should be okay, as we suppress implicit 'any' property access checks
var x = {}["hi"];
>x : any
>{}["hi"] : any
>{} : {}
>"hi" : string
// Should be okay, as we suppress implicit 'any' property access checks
var y = {}[10];
>y : any
>{}[10] : any
>{} : {}
>10 : number
var hi: any = "hi";
>hi : any
>"hi" : string
var emptyObj = {};
>emptyObj : any
>{} : {}
// Should be okay, as we suppress implicit 'any' property access checks
var z1 = emptyObj[hi];
>z1 : any
>emptyObj[hi] : any
>emptyObj : {}
>hi : any
var z2 = (<any>emptyObj)[hi];
>z2 : any
>(<any>emptyObj)[hi] : any
>(<any>emptyObj) : any
><any>emptyObj : any
>emptyObj : {}
>hi : any
interface MyMap<T> {
>MyMap : MyMap<T>
>T : T
[key: string]: T;
>key : string
>T : T
}
var m: MyMap<number> = {
>m : MyMap<number>
>MyMap : MyMap<T>
>{ "0": 0, "1": 1, "2": 2, "Okay that's enough for today.": NaN} : { "0": number; "1": number; "2": number; "Okay that's enough for today.": number; }
"0": 0,
>0 : number
"1": 1,
>1 : number
"2": 2,
>2 : number
"Okay that's enough for today.": NaN
>NaN : number
};
var mResult1 = m[MyEmusEnum.emu];
>mResult1 : number
>m[MyEmusEnum.emu] : number
>m : MyMap<number>
>MyEmusEnum.emu : MyEmusEnum
>MyEmusEnum : typeof MyEmusEnum
>emu : MyEmusEnum
var mResult2 = m[MyEmusEnum[MyEmusEnum.emu]];
>mResult2 : number
>m[MyEmusEnum[MyEmusEnum.emu]] : number
>m : MyMap<number>
>MyEmusEnum[MyEmusEnum.emu] : string
>MyEmusEnum : typeof MyEmusEnum
>MyEmusEnum.emu : MyEmusEnum
>MyEmusEnum : typeof MyEmusEnum
>emu : MyEmusEnum
var mResult3 = m[hi];
>mResult3 : number
>m[hi] : number
>m : MyMap<number>
>hi : any

Просмотреть файл

@ -0,0 +1,14 @@
=== tests/cases/conformance/es6/destructuring/nonIterableRestElement1.ts ===
var c = {};
>c : any
>{} : {}
[...c] = ["", 0];
>[...c] = ["", 0] : (string | number)[]
>[...c] : undefined[]
>...c : any
>c : any
>["", 0] : (string | number)[]
>"" : string
>0 : number

Просмотреть файл

@ -0,0 +1,14 @@
=== tests/cases/conformance/es6/destructuring/nonIterableRestElement2.ts ===
var c = {};
>c : any
>{} : {}
[...c] = ["", 0];
>[...c] = ["", 0] : (string | number)[]
>[...c] : undefined[]
>...c : any
>c : any
>["", 0] : (string | number)[]
>"" : string
>0 : number

Просмотреть файл

@ -0,0 +1,37 @@
=== tests/cases/compiler/objectLitGetterSetter.ts ===
var obj = {};
>obj : any
>{} : {}
Object.defineProperty(obj, "accProperty", <PropertyDescriptor>({
>Object.defineProperty(obj, "accProperty", <PropertyDescriptor>({ get: function () { eval("public = 1;"); return 11; }, set: function (v) { } })) : any
>Object.defineProperty : (o: any, p: string, attributes: PropertyDescriptor) => any
>Object : ObjectConstructor
>defineProperty : (o: any, p: string, attributes: PropertyDescriptor) => any
>obj : {}
>"accProperty" : string
><PropertyDescriptor>({ get: function () { eval("public = 1;"); return 11; }, set: function (v) { } }) : PropertyDescriptor
>PropertyDescriptor : PropertyDescriptor
>({ get: function () { eval("public = 1;"); return 11; }, set: function (v) { } }) : { get: () => number; set: (v: any) => void; }
>{ get: function () { eval("public = 1;"); return 11; }, set: function (v) { } } : { get: () => number; set: (v: any) => void; }
get: function () {
>get : () => number
>function () { eval("public = 1;"); return 11; } : () => number
eval("public = 1;");
>eval("public = 1;") : any
>eval : (x: string) => any
>"public = 1;" : string
return 11;
>11 : number
},
set: function (v) {
>set : (v: any) => void
>function (v) { } : (v: any) => void
>v : any
}
}))

Просмотреть файл

@ -0,0 +1,61 @@
=== tests/cases/compiler/trailingCommasES3.ts ===
var o1 = { a: 1, b: 2 };
>o1 : { a: number; b: number; }
>{ a: 1, b: 2 } : { a: number; b: number; }
>a : number
>1 : number
>b : number
>2 : number
var o2 = { a: 1, b: 2, };
>o2 : { a: number; b: number; }
>{ a: 1, b: 2, } : { a: number; b: number; }
>a : number
>1 : number
>b : number
>2 : number
var o3 = { a: 1, };
>o3 : { a: number; }
>{ a: 1, } : { a: number; }
>a : number
>1 : number
var o4 = {};
>o4 : any
>{} : {}
var a1 = [1, 2];
>a1 : number[]
>[1, 2] : number[]
>1 : number
>2 : number
var a2 = [1, 2, ];
>a2 : number[]
>[1, 2, ] : number[]
>1 : number
>2 : number
var a3 = [1, ];
>a3 : number[]
>[1, ] : number[]
>1 : number
var a4 = [];
>a4 : any[]
>[] : undefined[]
var a5 = [1, , ];
>a5 : number[]
>[1, , ] : number[]
>1 : number
> : undefined
var a6 = [, , ];
>a6 : any[]
>[, , ] : undefined[]
> : undefined
> : undefined

Просмотреть файл

@ -0,0 +1,61 @@
=== tests/cases/compiler/trailingCommasES5.ts ===
var o1 = { a: 1, b: 2 };
>o1 : { a: number; b: number; }
>{ a: 1, b: 2 } : { a: number; b: number; }
>a : number
>1 : number
>b : number
>2 : number
var o2 = { a: 1, b: 2, };
>o2 : { a: number; b: number; }
>{ a: 1, b: 2, } : { a: number; b: number; }
>a : number
>1 : number
>b : number
>2 : number
var o3 = { a: 1, };
>o3 : { a: number; }
>{ a: 1, } : { a: number; }
>a : number
>1 : number
var o4 = {};
>o4 : any
>{} : {}
var a1 = [1, 2];
>a1 : number[]
>[1, 2] : number[]
>1 : number
>2 : number
var a2 = [1, 2, ];
>a2 : number[]
>[1, 2, ] : number[]
>1 : number
>2 : number
var a3 = [1, ];
>a3 : number[]
>[1, ] : number[]
>1 : number
var a4 = [];
>a4 : any[]
>[] : undefined[]
var a5 = [1, , ];
>a5 : number[]
>[1, , ] : number[]
>1 : number
> : undefined
var a6 = [, , ];
>a6 : any[]
>[, , ] : undefined[]
> : undefined
> : undefined

Просмотреть файл

@ -165,7 +165,7 @@ out().then(() => {
// Using Es6 proxy
var t = {}
>t : {}
>t : any
>{} : {}
var p = new Proxy(t, {});

Просмотреть файл

@ -165,7 +165,7 @@ out().then(() => {
// Using Es6 proxy
var t = {}
>t : {}
>t : any
>{} : {}
var p = new Proxy(t, {});

Просмотреть файл

@ -165,7 +165,7 @@ out().then(() => {
// Using Es6 proxy
var t = {}
>t : {}
>t : any
>{} : {}
var p = new Proxy(t, {});

Просмотреть файл

@ -88,7 +88,7 @@ o.hasOwnProperty(Symbol.hasInstance);
// Using Es6 proxy
var t = {}
>t : {}
>t : any
>{} : {}
var p = new Proxy(t, {});

Просмотреть файл

@ -6,7 +6,7 @@ var s = Symbol();
>Symbol : SymbolConstructor
var t = {};
>t : {}
>t : any
>{} : {}
var p = new Proxy(t, {});

Просмотреть файл

@ -57,7 +57,7 @@ var hi: any = "hi";
>"hi" : string
var emptyObj = {};
>emptyObj : {}
>emptyObj : any
>{} : {}
// Should be okay, as we suppress implicit 'any' property access checks

Просмотреть файл

@ -1,13 +1,13 @@
=== tests/cases/conformance/es6/destructuring/nonIterableRestElement1.ts ===
var c = {};
>c : {}
>c : any
>{} : {}
[...c] = ["", 0];
>[...c] = ["", 0] : (string | number)[]
>[...c] : undefined[]
>...c : any
>c : {}
>c : any
>["", 0] : (string | number)[]
>"" : string
>0 : number

Просмотреть файл

@ -1,13 +1,13 @@
=== tests/cases/conformance/es6/destructuring/nonIterableRestElement2.ts ===
var c = {};
>c : {}
>c : any
>{} : {}
[...c] = ["", 0];
>[...c] = ["", 0] : (string | number)[]
>[...c] : undefined[]
>...c : any
>c : {}
>c : any
>["", 0] : (string | number)[]
>"" : string
>0 : number

Просмотреть файл

@ -1,6 +1,6 @@
=== tests/cases/compiler/objectLitGetterSetter.ts ===
var obj = {};
>obj : {}
>obj : any
>{} : {}
Object.defineProperty(obj, "accProperty", <PropertyDescriptor>({

Просмотреть файл

@ -23,7 +23,7 @@ var o3 = { a: 1, };
>1 : number
var o4 = {};
>o4 : {}
>o4 : any
>{} : {}
var a1 = [1, 2];

Просмотреть файл

@ -23,7 +23,7 @@ var o3 = { a: 1, };
>1 : number
var o4 = {};
>o4 : {}
>o4 : any
>{} : {}
var a1 = [1, 2];