mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00:00
Merge branch 'master' into untyped_module_symbol
This commit is contained in:
commit
acf317cb13
2256 files changed
+162805
-128283
No files matched your search
@@ -0,0 +1,15 @@
|
||||
// target: es5
|
||||
type MyType = {
|
||||
arguments: Array<string>
|
||||
}
|
||||
|
||||
declare function use(s: any);
|
||||
|
||||
function myFunction(myType: MyType) {
|
||||
for (let i = 0; i < 10; i++) {
|
||||
use(myType.arguments[i]);
|
||||
// create closure so that tsc will turn loop body into function
|
||||
const x = 5;
|
||||
[1, 2, 3].forEach(function(j) { use(x); })
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
var arr: string[] | number[];
|
||||
arr.splice(1, 1);
|
||||
@@ -8,3 +8,69 @@ async function fAsyncExplicit(): Promise<[number, boolean]> {
|
||||
// This is contextually typed as a tuple.
|
||||
return [1, true];
|
||||
}
|
||||
|
||||
// https://github.com/Microsoft/TypeScript/issues/13128
|
||||
interface Obj {
|
||||
stringProp: string;
|
||||
anyProp: any;
|
||||
}
|
||||
|
||||
async function fIndexedTypeForStringProp(obj: Obj): Promise<Obj["stringProp"]> {
|
||||
return obj.stringProp;
|
||||
}
|
||||
|
||||
async function fIndexedTypeForPromiseOfStringProp(obj: Obj): Promise<Obj["stringProp"]> {
|
||||
return Promise.resolve(obj.stringProp);
|
||||
}
|
||||
|
||||
async function fIndexedTypeForExplicitPromiseOfStringProp(obj: Obj): Promise<Obj["stringProp"]> {
|
||||
return Promise.resolve<Obj["stringProp"]>(obj.stringProp);
|
||||
}
|
||||
|
||||
async function fIndexedTypeForAnyProp(obj: Obj): Promise<Obj["anyProp"]> {
|
||||
return obj.anyProp;
|
||||
}
|
||||
|
||||
async function fIndexedTypeForPromiseOfAnyProp(obj: Obj): Promise<Obj["anyProp"]> {
|
||||
return Promise.resolve(obj.anyProp);
|
||||
}
|
||||
|
||||
async function fIndexedTypeForExplicitPromiseOfAnyProp(obj: Obj): Promise<Obj["anyProp"]> {
|
||||
return Promise.resolve<Obj["anyProp"]>(obj.anyProp);
|
||||
}
|
||||
|
||||
async function fGenericIndexedTypeForStringProp<TObj extends Obj>(obj: TObj): Promise<TObj["stringProp"]> {
|
||||
return obj.stringProp;
|
||||
}
|
||||
|
||||
async function fGenericIndexedTypeForPromiseOfStringProp<TObj extends Obj>(obj: TObj): Promise<TObj["stringProp"]> {
|
||||
return Promise.resolve(obj.stringProp);
|
||||
}
|
||||
|
||||
async function fGenericIndexedTypeForExplicitPromiseOfStringProp<TObj extends Obj>(obj: TObj): Promise<TObj["stringProp"]> {
|
||||
return Promise.resolve<TObj["stringProp"]>(obj.stringProp);
|
||||
}
|
||||
|
||||
async function fGenericIndexedTypeForAnyProp<TObj extends Obj>(obj: TObj): Promise<TObj["anyProp"]> {
|
||||
return obj.anyProp;
|
||||
}
|
||||
|
||||
async function fGenericIndexedTypeForPromiseOfAnyProp<TObj extends Obj>(obj: TObj): Promise<TObj["anyProp"]> {
|
||||
return Promise.resolve(obj.anyProp);
|
||||
}
|
||||
|
||||
async function fGenericIndexedTypeForExplicitPromiseOfAnyProp<TObj extends Obj>(obj: TObj): Promise<TObj["anyProp"]> {
|
||||
return Promise.resolve<TObj["anyProp"]>(obj.anyProp);
|
||||
}
|
||||
|
||||
async function fGenericIndexedTypeForKProp<TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K): Promise<TObj[K]> {
|
||||
return obj[key];
|
||||
}
|
||||
|
||||
async function fGenericIndexedTypeForPromiseOfKProp<TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K): Promise<TObj[K]> {
|
||||
return Promise.resolve(obj[key]);
|
||||
}
|
||||
|
||||
async function fGenericIndexedTypeForExplicitPromiseOfKProp<TObj extends Obj, K extends keyof TObj>(obj: TObj, key: K): Promise<TObj[K]> {
|
||||
return Promise.resolve<TObj[K]>(obj[key]);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// @module: amd
|
||||
// @importHelpers: true
|
||||
// @traceResolution: true
|
||||
|
||||
// @filename: /a/b/c/app.ts
|
||||
export let x = 1;
|
||||
|
||||
// @filename: /a/b/c/lib1.ts
|
||||
export let x = 1;
|
||||
|
||||
// @filename: /a/b/c/lib2.ts
|
||||
export let x = 1;
|
||||
@@ -0,0 +1,11 @@
|
||||
// @moduleResolution: node
|
||||
// @traceResolution: true
|
||||
|
||||
// @filename: /a/b/node_modules/foo.d.ts
|
||||
export declare let x: number
|
||||
|
||||
// @filename: /a/b/c/d/e/app.ts
|
||||
import {x} from "foo";
|
||||
|
||||
// @filename: /a/b/c/lib.ts
|
||||
import {x} from "foo";
|
||||
@@ -0,0 +1,11 @@
|
||||
// @moduleResolution: node
|
||||
// @traceResolution: true
|
||||
|
||||
// @filename: /a/b/node_modules/foo.d.ts
|
||||
export declare let x: number
|
||||
|
||||
// @filename: /a/b/c/lib.ts
|
||||
import {x} from "foo";
|
||||
|
||||
// @filename: /a/b/c/d/e/app.ts
|
||||
import {x} from "foo";
|
||||
@@ -0,0 +1,11 @@
|
||||
// @moduleResolution: classic
|
||||
// @traceResolution: true
|
||||
|
||||
// @filename: /a/b/foo.d.ts
|
||||
export declare let x: number
|
||||
|
||||
// @filename: /a/b/c/d/e/app.ts
|
||||
import {x} from "foo";
|
||||
|
||||
// @filename: /a/b/c/lib.ts
|
||||
import {x} from "foo";
|
||||
@@ -0,0 +1,11 @@
|
||||
// @moduleResolution: classic
|
||||
// @traceResolution: true
|
||||
|
||||
// @filename: /a/b/foo.d.ts
|
||||
export declare let x: number
|
||||
|
||||
// @filename: /a/b/c/lib.ts
|
||||
import {x} from "foo";
|
||||
|
||||
// @filename: /a/b/c/d/e/app.ts
|
||||
import {x} from "foo";
|
||||
@@ -0,0 +1,11 @@
|
||||
// @moduleResolution: node
|
||||
// @traceResolution: true
|
||||
|
||||
// @filename: /a/b/node_modules/foo.d.ts
|
||||
export declare let x: number
|
||||
|
||||
// @filename: /a/b/c/d/e/app.ts
|
||||
import {x} from "foo";
|
||||
|
||||
// @filename: /a/b/lib.ts
|
||||
import {x} from "foo";
|
||||
@@ -0,0 +1,8 @@
|
||||
// @moduleResolution: node
|
||||
// @traceResolution: true
|
||||
|
||||
// @filename: /a/b/c/d/e/app.ts
|
||||
import {x} from "foo";
|
||||
|
||||
// @filename: /a/b/c/lib.ts
|
||||
import {x} from "foo";
|
||||
@@ -0,0 +1,8 @@
|
||||
// @moduleResolution: node
|
||||
// @traceResolution: true
|
||||
|
||||
// @filename: /a/b/c/lib.ts
|
||||
import {x} from "foo";
|
||||
|
||||
// @filename: /a/b/c/d/e/app.ts
|
||||
import {x} from "foo";
|
||||
@@ -0,0 +1,8 @@
|
||||
// @moduleResolution: classic
|
||||
// @traceResolution: true
|
||||
|
||||
// @filename: /a/b/c/d/e/app.ts
|
||||
import {x} from "foo";
|
||||
|
||||
// @filename: /a/b/c/lib.ts
|
||||
import {x} from "foo";
|
||||
@@ -0,0 +1,9 @@
|
||||
// @moduleResolution: classic
|
||||
// @traceResolution: true
|
||||
|
||||
// @filename: /a/b/c/lib.ts
|
||||
import {x} from "foo";
|
||||
|
||||
|
||||
// @filename: /a/b/c/d/e/app.ts
|
||||
import {x} from "foo";
|
||||
@@ -0,0 +1,11 @@
|
||||
class A {
|
||||
constructor(f: () => string) {
|
||||
}
|
||||
public blah(): string { return ""; }
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
constructor() {
|
||||
super(() => { return super.blah(); })
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// @declaration: true
|
||||
|
||||
// @filename: db.d.ts
|
||||
declare namespace Db {
|
||||
export import Types = Db;
|
||||
}
|
||||
|
||||
export = Db;
|
||||
|
||||
// @filename: app.ts
|
||||
import * as Db from "./db"
|
||||
|
||||
export function foo() {
|
||||
return new Object()
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
function f (m: string) {
|
||||
[1, 2, 3].map(i => {
|
||||
return true? { [m]: i } : { [m]: i + 1 }
|
||||
})
|
||||
}
|
||||
+11
-33
@@ -1,8 +1,10 @@
|
||||
// @strictNullChecks: true
|
||||
// @allowJs: true
|
||||
// @Filename: controlFlowJavascript.js
|
||||
// @out: out.js
|
||||
|
||||
declare let cond: boolean;
|
||||
let cond = true;
|
||||
|
||||
// CFA for 'let' with no type annotation and initializer
|
||||
// CFA for 'let' and no initializer
|
||||
function f1() {
|
||||
let x;
|
||||
if (cond) {
|
||||
@@ -14,7 +16,7 @@ function f1() {
|
||||
const y = x; // string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'let' with no type annotation and 'undefined' initializer
|
||||
// CFA for 'let' and 'undefined' initializer
|
||||
function f2() {
|
||||
let x = undefined;
|
||||
if (cond) {
|
||||
@@ -26,7 +28,7 @@ function f2() {
|
||||
const y = x; // string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'let' with no type annotation and 'null' initializer
|
||||
// CFA for 'let' and 'null' initializer
|
||||
function f3() {
|
||||
let x = null;
|
||||
if (cond) {
|
||||
@@ -38,19 +40,7 @@ function f3() {
|
||||
const y = x; // string | number | null
|
||||
}
|
||||
|
||||
// No CFA for 'let' with with type annotation
|
||||
function f4() {
|
||||
let x: any;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // any
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and initializer
|
||||
// CFA for 'var' with no initializer
|
||||
function f5() {
|
||||
var x;
|
||||
if (cond) {
|
||||
@@ -62,7 +52,7 @@ function f5() {
|
||||
const y = x; // string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and 'undefined' initializer
|
||||
// CFA for 'var' with 'undefined' initializer
|
||||
function f6() {
|
||||
var x = undefined;
|
||||
if (cond) {
|
||||
@@ -74,7 +64,7 @@ function f6() {
|
||||
const y = x; // string | number | undefined
|
||||
}
|
||||
|
||||
// CFA for 'var' with no type annotation and 'null' initializer
|
||||
// CFA for 'var' with 'null' initializer
|
||||
function f7() {
|
||||
var x = null;
|
||||
if (cond) {
|
||||
@@ -86,18 +76,6 @@ function f7() {
|
||||
const y = x; // string | number | null
|
||||
}
|
||||
|
||||
// No CFA for 'var' with with type annotation
|
||||
function f8() {
|
||||
var x: any;
|
||||
if (cond) {
|
||||
x = 1;
|
||||
}
|
||||
if (cond) {
|
||||
x = "hello";
|
||||
}
|
||||
const y = x; // any
|
||||
}
|
||||
|
||||
// No CFA for captured outer variables
|
||||
function f9() {
|
||||
let x;
|
||||
@@ -126,4 +104,4 @@ function f10() {
|
||||
const f = () => {
|
||||
const z = x; // any
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
// @noimplicitany: true
|
||||
|
||||
// Repro from #12319
|
||||
|
||||
function md5(string:string): void {
|
||||
|
||||
function FF(a,b,c,d,x,s,ac) {
|
||||
return 0;
|
||||
};
|
||||
|
||||
function GG(a,b,c,d,x,s,ac) {
|
||||
return 0;
|
||||
};
|
||||
|
||||
function HH(a,b,c,d,x,s,ac) {
|
||||
return 0;
|
||||
};
|
||||
|
||||
function II(a,b,c,d,x,s,ac) {
|
||||
return 0;
|
||||
};
|
||||
|
||||
var x=Array();
|
||||
var k,AA,BB,CC,DD,a,b,c,d;
|
||||
var S11=7, S12=12, S13=17, S14=22;
|
||||
var S21=5, S22=9 , S23=14, S24=20;
|
||||
var S31=4, S32=11, S33=16, S34=23;
|
||||
var S41=6, S42=10, S43=15, S44=21;
|
||||
|
||||
x = [1];
|
||||
|
||||
a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476;
|
||||
|
||||
for (k=0;k<x.length;k+=16) {
|
||||
AA=a; BB=b; CC=c; DD=d;
|
||||
a=FF(a,b,c,d,x[k+0], S11,0xD76AA478);
|
||||
d=FF(d,a,b,c,x[k+1], S12,0xE8C7B756);
|
||||
c=FF(c,d,a,b,x[k+2], S13,0x242070DB);
|
||||
b=FF(b,c,d,a,x[k+3], S14,0xC1BDCEEE);
|
||||
a=FF(a,b,c,d,x[k+4], S11,0xF57C0FAF);
|
||||
d=FF(d,a,b,c,x[k+5], S12,0x4787C62A);
|
||||
c=FF(c,d,a,b,x[k+6], S13,0xA8304613);
|
||||
b=FF(b,c,d,a,x[k+7], S14,0xFD469501);
|
||||
a=FF(a,b,c,d,x[k+8], S11,0x698098D8);
|
||||
d=FF(d,a,b,c,x[k+9], S12,0x8B44F7AF);
|
||||
c=FF(c,d,a,b,x[k+10],S13,0xFFFF5BB1);
|
||||
b=FF(b,c,d,a,x[k+11],S14,0x895CD7BE);
|
||||
a=FF(a,b,c,d,x[k+12],S11,0x6B901122);
|
||||
d=FF(d,a,b,c,x[k+13],S12,0xFD987193);
|
||||
c=FF(c,d,a,b,x[k+14],S13,0xA679438E);
|
||||
b=FF(b,c,d,a,x[k+15],S14,0x49B40821);
|
||||
a=GG(a,b,c,d,x[k+1], S21,0xF61E2562);
|
||||
d=GG(d,a,b,c,x[k+6], S22,0xC040B340);
|
||||
c=GG(c,d,a,b,x[k+11],S23,0x265E5A51);
|
||||
b=GG(b,c,d,a,x[k+0], S24,0xE9B6C7AA);
|
||||
a=GG(a,b,c,d,x[k+5], S21,0xD62F105D);
|
||||
d=GG(d,a,b,c,x[k+10],S22,0x2441453);
|
||||
c=GG(c,d,a,b,x[k+15],S23,0xD8A1E681);
|
||||
b=GG(b,c,d,a,x[k+4], S24,0xE7D3FBC8);
|
||||
a=GG(a,b,c,d,x[k+9], S21,0x21E1CDE6);
|
||||
d=GG(d,a,b,c,x[k+14],S22,0xC33707D6);
|
||||
c=GG(c,d,a,b,x[k+3], S23,0xF4D50D87);
|
||||
b=GG(b,c,d,a,x[k+8], S24,0x455A14ED);
|
||||
a=GG(a,b,c,d,x[k+13],S21,0xA9E3E905);
|
||||
d=GG(d,a,b,c,x[k+2], S22,0xFCEFA3F8);
|
||||
c=GG(c,d,a,b,x[k+7], S23,0x676F02D9);
|
||||
b=GG(b,c,d,a,x[k+12],S24,0x8D2A4C8A);
|
||||
a=HH(a,b,c,d,x[k+5], S31,0xFFFA3942);
|
||||
d=HH(d,a,b,c,x[k+8], S32,0x8771F681);
|
||||
c=HH(c,d,a,b,x[k+11],S33,0x6D9D6122);
|
||||
b=HH(b,c,d,a,x[k+14],S34,0xFDE5380C);
|
||||
a=HH(a,b,c,d,x[k+1], S31,0xA4BEEA44);
|
||||
d=HH(d,a,b,c,x[k+4], S32,0x4BDECFA9);
|
||||
c=HH(c,d,a,b,x[k+7], S33,0xF6BB4B60);
|
||||
b=HH(b,c,d,a,x[k+10],S34,0xBEBFBC70);
|
||||
a=HH(a,b,c,d,x[k+13],S31,0x289B7EC6);
|
||||
d=HH(d,a,b,c,x[k+0], S32,0xEAA127FA);
|
||||
c=HH(c,d,a,b,x[k+3], S33,0xD4EF3085);
|
||||
b=HH(b,c,d,a,x[k+6], S34,0x4881D05);
|
||||
a=HH(a,b,c,d,x[k+9], S31,0xD9D4D039);
|
||||
d=HH(d,a,b,c,x[k+12],S32,0xE6DB99E5);
|
||||
c=HH(c,d,a,b,x[k+15],S33,0x1FA27CF8);
|
||||
b=HH(b,c,d,a,x[k+2], S34,0xC4AC5665);
|
||||
a=II(a,b,c,d,x[k+0], S41,0xF4292244);
|
||||
d=II(d,a,b,c,x[k+7], S42,0x432AFF97);
|
||||
c=II(c,d,a,b,x[k+14],S43,0xAB9423A7);
|
||||
b=II(b,c,d,a,x[k+5], S44,0xFC93A039);
|
||||
a=II(a,b,c,d,x[k+12],S41,0x655B59C3);
|
||||
d=II(d,a,b,c,x[k+3], S42,0x8F0CCC92);
|
||||
c=II(c,d,a,b,x[k+10],S43,0xFFEFF47D);
|
||||
b=II(b,c,d,a,x[k+1], S44,0x85845DD1);
|
||||
a=II(a,b,c,d,x[k+8], S41,0x6FA87E4F);
|
||||
d=II(d,a,b,c,x[k+15],S42,0xFE2CE6E0);
|
||||
c=II(c,d,a,b,x[k+6], S43,0xA3014314);
|
||||
b=II(b,c,d,a,x[k+13],S44,0x4E0811A1);
|
||||
a=II(a,b,c,d,x[k+4], S41,0xF7537E82);
|
||||
d=II(d,a,b,c,x[k+11],S42,0xBD3AF235);
|
||||
c=II(c,d,a,b,x[k+2], S43,0x2AD7D2BB);
|
||||
b=II(b,c,d,a,x[k+9], S44,0xEB86D391);
|
||||
}
|
||||
}
|
||||
export default md5;
|
||||
@@ -0,0 +1,5 @@
|
||||
// @declaration: true
|
||||
|
||||
export interface Test {
|
||||
[index: TypeNotFound]: any;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// @declaration: true
|
||||
|
||||
class A { }
|
||||
interface Class extends (typeof A) { }
|
||||
@@ -0,0 +1,3 @@
|
||||
// @declaration: true
|
||||
|
||||
type A<T extends Unknown> = {}
|
||||
@@ -0,0 +1,42 @@
|
||||
// @experimentalDecorators: true
|
||||
// @emitDecoratorMetadata: true
|
||||
// @target: es5
|
||||
|
||||
// @filename: aux.ts
|
||||
export class SomeClass {
|
||||
field: string;
|
||||
}
|
||||
|
||||
// @filename: aux1.ts
|
||||
export class SomeClass1 {
|
||||
field: string;
|
||||
}
|
||||
|
||||
// @filename: aux2.ts
|
||||
export class SomeClass2 {
|
||||
field: string;
|
||||
}
|
||||
// @filename: main.ts
|
||||
import { SomeClass } from './aux';
|
||||
import { SomeClass1 } from './aux1';
|
||||
|
||||
function annotation(): ClassDecorator {
|
||||
return (target: any): void => { };
|
||||
}
|
||||
|
||||
function annotation1(): MethodDecorator {
|
||||
return (target: any): void => { };
|
||||
}
|
||||
|
||||
@annotation()
|
||||
export class ClassA {
|
||||
array: SomeClass[];
|
||||
|
||||
constructor(...init: SomeClass[]) {
|
||||
this.array = init;
|
||||
}
|
||||
|
||||
@annotation1()
|
||||
foo(... args: SomeClass1[]) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// @noemithelpers: true
|
||||
// @experimentaldecorators: true
|
||||
|
||||
declare var console : { log(arg: string): void };
|
||||
function dec(): Function {
|
||||
return function (target: any, propKey: string, descr: PropertyDescriptor): void {
|
||||
console.log(target[propKey]);
|
||||
//logs undefined
|
||||
//propKey has three underscores as prefix, but the method has only two underscores
|
||||
};
|
||||
}
|
||||
|
||||
class A {
|
||||
@dec()
|
||||
private __foo(bar: string): void {
|
||||
// do something with bar
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
interface A {
|
||||
readonly b
|
||||
}
|
||||
var a: A = {
|
||||
b: 123
|
||||
};
|
||||
|
||||
delete a.b;
|
||||
|
||||
interface B {
|
||||
readonly [k: string]: string
|
||||
}
|
||||
|
||||
var b: B = {
|
||||
'test': 'test'
|
||||
};
|
||||
|
||||
delete b['test'];
|
||||
|
||||
delete ((((b['test']))));
|
||||
@@ -0,0 +1,9 @@
|
||||
// @target: ES3
|
||||
// @sourcemap: false
|
||||
// @declaration: false
|
||||
// @jsx: preserve
|
||||
|
||||
const React: any = null;
|
||||
|
||||
const elem = <div></div>;
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// @target: ES3
|
||||
// @sourcemap: false
|
||||
// @declaration: false
|
||||
// @jsx: react-native
|
||||
|
||||
const React: any = null;
|
||||
|
||||
const elem = <div></div>;
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// @target: ES3
|
||||
// @sourcemap: false
|
||||
// @declaration: false
|
||||
// @jsx: react
|
||||
|
||||
const React: any = null;
|
||||
|
||||
const elem = <div></div>;
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// @target: ES3
|
||||
enum E {
|
||||
x = -01,
|
||||
y = 02,
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
// @target: ES3
|
||||
let x: 010;
|
||||
let y: -020;
|
||||
@@ -0,0 +1,5 @@
|
||||
// @target: ES5
|
||||
enum E {
|
||||
x = -01,
|
||||
y = 02,
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// @strictNullChecks: true
|
||||
|
||||
// Repro from #12529
|
||||
|
||||
class A {
|
||||
readonly kind = "A"; // (property) A.kind: "A"
|
||||
}
|
||||
|
||||
class B {
|
||||
readonly kind = "B"; // (property) B.kind: "B"
|
||||
}
|
||||
|
||||
function f(value: A | B): number {
|
||||
switch(value.kind) {
|
||||
case "A": return 0;
|
||||
case "B": return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
// @noImplicitAny: true
|
||||
({ a: [], ...(null as any) });
|
||||
let x: any;
|
||||
@@ -0,0 +1,9 @@
|
||||
// @importHelpers: true
|
||||
// @target: es5
|
||||
// @module: commonjs
|
||||
// @moduleResolution: classic
|
||||
// @filename: declaration.d.ts
|
||||
export declare class D {
|
||||
}
|
||||
export declare class E extends D {
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// @importHelpers: true
|
||||
// @target: es5
|
||||
|
||||
// @filename: a.d.ts
|
||||
export { };
|
||||
|
||||
// Extends
|
||||
declare class C { }
|
||||
declare class D extends C { }
|
||||
|
||||
// Destructuring
|
||||
interface I {
|
||||
({descendants, read}?: {
|
||||
descendants?: boolean;
|
||||
read?: any;
|
||||
}): any;
|
||||
}
|
||||
|
||||
|
||||
// Object Rest
|
||||
interface Foo {
|
||||
a: number; b: string;
|
||||
}
|
||||
export var { a, ...x } : Foo;
|
||||
|
||||
// @filename: b.ts
|
||||
export {};
|
||||
declare namespace N {
|
||||
// Extends
|
||||
class C { }
|
||||
class D extends C { }
|
||||
|
||||
// Destructuring
|
||||
interface I {
|
||||
({descendants, read}?: {
|
||||
descendants?: boolean;
|
||||
read?: any;
|
||||
}): any;
|
||||
}
|
||||
|
||||
|
||||
// Object Rest
|
||||
interface Foo {
|
||||
a: number; b: string;
|
||||
}
|
||||
export var { a, ...x } : Foo;
|
||||
}
|
||||
|
||||
// @filename: tslib.d.ts
|
||||
export declare function __extends(d: Function, b: Function): void;
|
||||
export declare function __assign(t: any, ...sources: any[]): any;
|
||||
export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any;
|
||||
export declare function __param(paramIndex: number, decorator: Function): Function;
|
||||
export declare function __metadata(metadataKey: any, metadataValue: any): Function;
|
||||
export declare function __awaiter(thisArg: any, _arguments: any, P: Function, generator: Function): any;
|
||||
@@ -57,4 +57,49 @@ function getValueAsString(value: IntersectionFail): string {
|
||||
return '' + value.num;
|
||||
}
|
||||
return value.str;
|
||||
}
|
||||
|
||||
// Repro from #12535
|
||||
|
||||
namespace enums {
|
||||
export const enum A {
|
||||
a1,
|
||||
a2,
|
||||
a3,
|
||||
// ... elements omitted for the sake of clarity
|
||||
a75,
|
||||
a76,
|
||||
a77,
|
||||
}
|
||||
export const enum B {
|
||||
b1,
|
||||
b2,
|
||||
// ... elements omitted for the sake of clarity
|
||||
b86,
|
||||
b87,
|
||||
}
|
||||
export const enum C {
|
||||
c1,
|
||||
c2,
|
||||
// ... elements omitted for the sake of clarity
|
||||
c210,
|
||||
c211,
|
||||
}
|
||||
export type Genre = A | B | C;
|
||||
}
|
||||
|
||||
type Foo = {
|
||||
genreId: enums.Genre;
|
||||
};
|
||||
|
||||
type Bar = {
|
||||
genreId: enums.Genre;
|
||||
};
|
||||
|
||||
type FooBar = Foo & Bar;
|
||||
|
||||
function foo(so: any) {
|
||||
const val = so as FooBar;
|
||||
const isGenre = val.genreId;
|
||||
return isGenre;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
type A = & string;
|
||||
type B =
|
||||
& { foo: string }
|
||||
& { bar: number };
|
||||
|
||||
type C = [& { foo: 1 } & { bar: 2 }, & { foo: 3 } & { bar: 4 }];
|
||||
@@ -0,0 +1,4 @@
|
||||
interface OhNo {
|
||||
}
|
||||
|
||||
declare let y: OhNo.hello;
|
||||
@@ -0,0 +1,9 @@
|
||||
//@jsx: react
|
||||
|
||||
declare var React: any;
|
||||
<View>
|
||||
<ListView refreshControl={
|
||||
<RefreshControl onRefresh={} refreshing={} />
|
||||
} dataSource={this.state.ds} renderRow={}>
|
||||
</ListView>
|
||||
</View>
|
||||
@@ -0,0 +1,17 @@
|
||||
//@module: commonjs
|
||||
//@target: es5
|
||||
//@jsx: react
|
||||
//@jsxFactory: skate.h
|
||||
//@noEmit: false
|
||||
|
||||
// @filename: index.tsx
|
||||
import "./jsx";
|
||||
|
||||
var skate: any;
|
||||
const React = { createElement: skate.h };
|
||||
|
||||
class Component {
|
||||
renderCallback() {
|
||||
return <div>test</div>;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
// @jsx: react
|
||||
// https://github.com/Microsoft/TypeScript/issues/13157
|
||||
declare namespace React {
|
||||
interface ComponentClass<P> { new (): Component<P, {}>; }
|
||||
class Component<A, B> {}
|
||||
}
|
||||
declare function createComponentClass<P>(factory: () => React.ComponentClass<P>): React.ComponentClass<P>;
|
||||
class Foo extends createComponentClass(() => class extends React.Component<{}, {}> {
|
||||
render() {
|
||||
return <span>Hello, world!</span>;
|
||||
}
|
||||
}) {}
|
||||
@@ -0,0 +1,23 @@
|
||||
//@jsx: preserve
|
||||
//@module: commonjs
|
||||
|
||||
//@filename: component.d.ts
|
||||
declare module JSX {
|
||||
interface ElementAttributesProperty { props; }
|
||||
}
|
||||
declare module React {
|
||||
class Component<T, U> { }
|
||||
}
|
||||
declare module "BaseComponent" {
|
||||
export default class extends React.Component<any, {}> {
|
||||
}
|
||||
}
|
||||
|
||||
//@filename: consumer.tsx
|
||||
/// <reference path="component.d.ts" />
|
||||
import BaseComponent from 'BaseComponent';
|
||||
class TestComponent extends React.Component<any, {}> {
|
||||
render() {
|
||||
return <BaseComponent />;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// keyof T is a literal contextual type
|
||||
|
||||
function foo<T extends { a: string, b: string }>() {
|
||||
let a: (keyof T)[] = ["a", "b"];
|
||||
let b: (keyof T)[] = ["a", "b", "c"];
|
||||
}
|
||||
|
||||
// Repro from #12455
|
||||
|
||||
declare function pick<T, K extends keyof T>(obj: T, propNames: K[]): Pick<T, K>;
|
||||
|
||||
let x = pick({ a: 10, b: 20, c: 30 }, ["a", "c"]);
|
||||
let b = x.b; // Error
|
||||
@@ -0,0 +1,7 @@
|
||||
// Repro from #12511
|
||||
|
||||
type HTML = { [K in 'div']: Block<HTML> };
|
||||
type Block<P> = <T>(func: HTML) => {};
|
||||
|
||||
declare var h: HTML;
|
||||
h.div(h);
|
||||
@@ -0,0 +1,12 @@
|
||||
// Repro from #13346
|
||||
|
||||
interface Chainable<T> {
|
||||
value(): T;
|
||||
mapValues<U>(func: (v: T[keyof T]) => U): Chainable<{[k in keyof T]: U}>;
|
||||
}
|
||||
|
||||
declare function chain<T>(t: T): Chainable<T>;
|
||||
|
||||
const square = (x: number) => x * x;
|
||||
|
||||
const v = chain({a: 1, b: 2}).mapValues(square).value();
|
||||
@@ -0,0 +1,18 @@
|
||||
// Repro from #13351
|
||||
|
||||
type Meta<T, A> = {
|
||||
readonly[P in keyof T]: {
|
||||
value: T[P];
|
||||
also: A;
|
||||
readonly children: Meta<T[P], A>;
|
||||
};
|
||||
}
|
||||
|
||||
interface Input {
|
||||
x: string;
|
||||
y: number;
|
||||
}
|
||||
|
||||
declare const output: Meta<Input, boolean>;
|
||||
|
||||
const shouldFail: { important: boolean } = output.x.children;
|
||||
@@ -0,0 +1,21 @@
|
||||
// @filename: passport.d.ts
|
||||
declare module 'passport' {
|
||||
namespace passport {
|
||||
interface Passport {
|
||||
use(): this;
|
||||
}
|
||||
|
||||
interface PassportStatic extends Passport {
|
||||
Passport: {new(): Passport};
|
||||
}
|
||||
}
|
||||
|
||||
const passport: passport.PassportStatic;
|
||||
export = passport;
|
||||
}
|
||||
|
||||
//@filename: test.ts
|
||||
import * as passport from "passport";
|
||||
import { Passport } from "passport";
|
||||
|
||||
let p: Passport = passport.use();
|
||||
@@ -0,0 +1,14 @@
|
||||
// @experimentalDecorators: true
|
||||
// @emitDecoratorMetadata: true
|
||||
// @target: es5
|
||||
module MyModule {
|
||||
|
||||
export function inject(target: any, key: string): void { }
|
||||
|
||||
export class Leg { }
|
||||
|
||||
export class Person {
|
||||
@inject leftLeg: Leg;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// @experimentalDecorators: true
|
||||
// @emitDecoratorMetadata: true
|
||||
// @target: es5
|
||||
// @includeBuiltFile: lib.d.ts
|
||||
|
||||
// @filename: event.ts
|
||||
export interface Event { title: string };
|
||||
|
||||
// @filename: test.ts
|
||||
import { Event } from './event';
|
||||
function Input(target: any, key: string): void { }
|
||||
export class SomeClass {
|
||||
@Input event: Event;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// @experimentalDecorators: true
|
||||
// @emitDecoratorMetadata: true
|
||||
function PropDeco(target: Object, propKey: string | symbol) { }
|
||||
|
||||
class A {
|
||||
}
|
||||
|
||||
class B {
|
||||
@PropDeco
|
||||
x: "foo" | null;
|
||||
|
||||
@PropDeco
|
||||
y: true | never;
|
||||
|
||||
@PropDeco
|
||||
z: "foo" | undefined;
|
||||
|
||||
@PropDeco
|
||||
a: null;
|
||||
|
||||
@PropDeco
|
||||
b: never;
|
||||
|
||||
@PropDeco
|
||||
c: undefined;
|
||||
|
||||
@PropDeco
|
||||
d: undefined | null;
|
||||
|
||||
@PropDeco
|
||||
e: symbol | null;
|
||||
|
||||
@PropDeco
|
||||
f: symbol | A;
|
||||
|
||||
@PropDeco
|
||||
g: A | null;
|
||||
|
||||
@PropDeco
|
||||
h: null | B;
|
||||
|
||||
@PropDeco
|
||||
j: null | symbol;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// @noImplicitReferences: true
|
||||
// @traceResolution: true
|
||||
// This tests that a package.json "main" with an unexpected extension is ignored.
|
||||
|
||||
// @Filename: /node_modules/normalize.css/normalize.css
|
||||
This file is not read.
|
||||
|
||||
// @Filename: /node_modules/normalize.css/package.json
|
||||
{ "main": "normalize.css" }
|
||||
|
||||
// @Filename: /a.ts
|
||||
import "normalize.css";
|
||||
@@ -0,0 +1,12 @@
|
||||
// @noImplicitReferences: true
|
||||
// @traceResolution: true
|
||||
// This tests that a package.json "types" with an unexpected extension is ignored.
|
||||
|
||||
// @Filename: /node_modules/foo/foo.js
|
||||
This file is not read.
|
||||
|
||||
// @Filename: /node_modules/foo/package.json
|
||||
{ "types": "foo.js" }
|
||||
|
||||
// @Filename: /a.ts
|
||||
import "foo";
|
||||
@@ -0,0 +1,14 @@
|
||||
// @strictNullChecks: true
|
||||
interface CSSProps {
|
||||
color?: string
|
||||
}
|
||||
interface NestedCSSProps {
|
||||
nested?: NestedSelector
|
||||
}
|
||||
interface NestedSelector {
|
||||
prop: CSSProps;
|
||||
}
|
||||
|
||||
let stylen: NestedCSSProps = {
|
||||
nested: { prop: { colour: 'red' } }
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// @target: es5
|
||||
export class Test {
|
||||
constructor() {
|
||||
|
||||
let outerArray: Array<number> = [1, 2, 3];
|
||||
let innerArray: Array<number> = [1, 2, 3];
|
||||
|
||||
for (let outer of outerArray)
|
||||
for (let inner of innerArray) {
|
||||
this.aFunction((newValue, oldValue) => {
|
||||
let x = outer + inner + newValue;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public aFunction(func: (newValue: any, oldValue: any) => void): void {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// @target: es5
|
||||
function baz(x: any) {
|
||||
return [[x, x]];
|
||||
}
|
||||
|
||||
function foo(set: any) {
|
||||
for (const [value, i] of baz(set.values)) {
|
||||
const bar: any = [];
|
||||
(() => bar);
|
||||
|
||||
set.values.push(...[]);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,10 @@
|
||||
// @outFile: out.js
|
||||
// @module: system
|
||||
// @moduleResolution: node
|
||||
// @noImplicitReferences: true
|
||||
|
||||
// @fileName: /node_modules/projB/index.ts
|
||||
export class C {}
|
||||
|
||||
// @fileName: /a.ts
|
||||
import { C } from "projB";
|
||||
@@ -0,0 +1,12 @@
|
||||
const f = Object.freeze(function foo(a: number, b: string) { return false; });
|
||||
f(1, "") === false;
|
||||
|
||||
class C { constructor(a: number) { } }
|
||||
const c = Object.freeze(C);
|
||||
new c(1);
|
||||
|
||||
const a = Object.freeze([1, 2, 3]);
|
||||
a[0] = a[2].toString();
|
||||
|
||||
const o = Object.freeze({ a: 1, b: "string" });
|
||||
o.b = o.a.toString();
|
||||
@@ -0,0 +1,4 @@
|
||||
var intersection: { x: number, y: number } & { w: string, z: string };
|
||||
|
||||
var rest1: { y: number, w: string, z: string };
|
||||
var {x, ...rest1 } = intersection;
|
||||
@@ -0,0 +1,59 @@
|
||||
enum E { v1, v2 };
|
||||
|
||||
function f<T extends { b: string }>(p1: T, p2: T[]) {
|
||||
var t: T;
|
||||
|
||||
var i: T["b"];
|
||||
var k: keyof T;
|
||||
|
||||
var mapped_generic: {[P in keyof T]: T[P]};
|
||||
var mapped: {[P in "b"]: T[P]};
|
||||
|
||||
var union_generic: T | { a: number };
|
||||
var union_primitive: { a: number } | number;
|
||||
|
||||
var intersection_generic: T & { a: number };
|
||||
var intersection_premitive: { a: number } | string;
|
||||
|
||||
var num: number;
|
||||
var str: number;
|
||||
|
||||
var u: undefined;
|
||||
var n: null;
|
||||
|
||||
var a: any;
|
||||
|
||||
var literal_string: "string";
|
||||
var literal_number: 42;
|
||||
|
||||
var e: E;
|
||||
|
||||
var {...r1} = p1; // Error, generic type paramterre
|
||||
var {...r2} = p2; // OK
|
||||
var {...r3} = t; // Error, generic type paramter
|
||||
|
||||
var {...r4} = i; // Error, index access
|
||||
var {...r5} = k; // Error, index
|
||||
|
||||
var {...r6} = mapped_generic; // Error, generic mapped object type
|
||||
var {...r7} = mapped; // OK, non-generic mapped type
|
||||
|
||||
var {...r8} = union_generic; // Error, union with generic type parameter
|
||||
var {...r9} = union_primitive; // Error, union with generic type parameter
|
||||
|
||||
var {...r10} = intersection_generic; // Error, intersection with generic type parameter
|
||||
var {...r11} = intersection_premitive; // Error, intersection with generic type parameter
|
||||
|
||||
var {...r12} = num; // Error
|
||||
var {...r13} = str; // Error
|
||||
|
||||
var {...r14} = u; // OK
|
||||
var {...r15} = n; // OK
|
||||
|
||||
var {...r16} = a; // OK
|
||||
|
||||
var {...r17} = literal_string; // Error
|
||||
var {...r18} = literal_number; // Error
|
||||
|
||||
var {...r19} = e; // Error, enum
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
var union: { a: number, c: boolean } | { a: string, b: string };
|
||||
|
||||
var rest1: { c: boolean } | { b: string };
|
||||
var {a, ...rest1 } = union;
|
||||
|
||||
|
||||
var undefinedUnion: { n: number } | undefined;
|
||||
var rest2: {};
|
||||
var {n, ...rest2 } = undefinedUnion;
|
||||
|
||||
|
||||
var nullUnion: { n: number } | null;
|
||||
var rest3: {};
|
||||
var {n, ...rest3 } = nullUnion;
|
||||
@@ -0,0 +1,19 @@
|
||||
// @strictNullChecks: true
|
||||
|
||||
declare const undefinedUnion: { n: number } | undefined;
|
||||
var rest2: { n: number };
|
||||
var {...rest2 } = undefinedUnion;
|
||||
|
||||
|
||||
declare const nullUnion: { n: number } | null;
|
||||
var rest3: { n: number };
|
||||
var {...rest3 } = nullUnion;
|
||||
|
||||
|
||||
declare const nullAndUndefinedUnion: null | undefined;
|
||||
var rest4: { };
|
||||
var {...rest4 } = nullAndUndefinedUnion;
|
||||
|
||||
declare const unionWithIntersection: ({ n: number } & { s: string }) & undefined | null;
|
||||
var rest5: { n: number, s: string };
|
||||
var {...rest5 } = unionWithIntersection;
|
||||
@@ -0,0 +1,5 @@
|
||||
// @noImplicitAny: true
|
||||
let additional = [];
|
||||
for (const subcomponent of [1, 2, 3]) {
|
||||
additional = [...additional, subcomponent];
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
var intersection: { a: number } & { b: string };
|
||||
|
||||
var o1: { a: number, b: string };
|
||||
var o1 = { ...intersection };
|
||||
|
||||
var o2: { a: number, b: string, c: boolean };
|
||||
var o2 = { ...intersection, c: false };
|
||||
@@ -0,0 +1,59 @@
|
||||
enum E { v1, v2 };
|
||||
|
||||
function f<T extends { b: string }>(p1: T, p2: T[]) {
|
||||
var t: T;
|
||||
|
||||
var i: T["b"];
|
||||
var k: keyof T;
|
||||
|
||||
var mapped_generic: {[P in keyof T]: T[P]};
|
||||
var mapped: {[P in "b"]: T[P]};
|
||||
|
||||
var union_generic: T | { a: number };
|
||||
var union_primitive: { a: number } | number;
|
||||
|
||||
var intersection_generic: T & { a: number };
|
||||
var intersection_premitive: { a: number } | string;
|
||||
|
||||
var num: number;
|
||||
var str: number;
|
||||
|
||||
var u: undefined;
|
||||
var n: null;
|
||||
|
||||
var a: any;
|
||||
|
||||
var literal_string: "string";
|
||||
var literal_number: 42;
|
||||
|
||||
var e: E;
|
||||
|
||||
var o1 = { ...p1 }; // Error, generic type paramterre
|
||||
var o2 = { ...p2 }; // OK
|
||||
var o3 = { ...t }; // Error, generic type paramter
|
||||
|
||||
var o4 = { ...i }; // Error, index access
|
||||
var o5 = { ...k }; // Error, index
|
||||
|
||||
var o6 = { ...mapped_generic }; // Error, generic mapped object type
|
||||
var o7 = { ...mapped }; // OK, non-generic mapped type
|
||||
|
||||
var o8 = { ...union_generic }; // Error, union with generic type parameter
|
||||
var o9 = { ...union_primitive }; // Error, union with generic type parameter
|
||||
|
||||
var o10 = { ...intersection_generic }; // Error, intersection with generic type parameter
|
||||
var o11 = { ...intersection_premitive }; // Error, intersection with generic type parameter
|
||||
|
||||
var o12 = { ...num }; // Error
|
||||
var o13 = { ...str }; // Error
|
||||
|
||||
var o14 = { ...u }; // OK
|
||||
var o15 = { ...n }; // OK
|
||||
|
||||
var o16 = { ...a }; // OK
|
||||
|
||||
var o17 = { ...literal_string }; // Error
|
||||
var o18 = { ...literal_number }; // Error
|
||||
|
||||
var o19 = { ...e }; // Error, enum
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
var union: { a: number } | { b: string };
|
||||
|
||||
var o3: { a: number } | { b: string };
|
||||
var o3 = { ...union };
|
||||
|
||||
var o4: { a: boolean } | { b: string , a: boolean};
|
||||
var o4 = { ...union, a: false };
|
||||
|
||||
var o5: { a: number } | { b: string } | { a: number, b: string };
|
||||
var o5 = { ...union, ...union };
|
||||
@@ -0,0 +1,25 @@
|
||||
// @strictNullChecks: true
|
||||
|
||||
declare const undefinedUnion: { a: number } | undefined;
|
||||
declare const nullUnion: { b: number } | null;
|
||||
declare const nullAndUndefinedUnion: null | undefined;
|
||||
|
||||
var o1: { a: number };
|
||||
var o1 = { ...undefinedUnion };
|
||||
|
||||
var o2: { b: number };
|
||||
var o2 = { ...nullUnion };
|
||||
|
||||
var o3: { a: number, b: number };
|
||||
var o3 = { ...undefinedUnion, ...nullUnion };
|
||||
var o3 = { ...nullUnion, ...undefinedUnion };
|
||||
|
||||
var o4: { a: number };
|
||||
var o4 = { ...undefinedUnion, ...undefinedUnion };
|
||||
|
||||
var o5: { b: number };
|
||||
var o5 = { ...nullUnion, ...nullUnion };
|
||||
|
||||
var o6: { };
|
||||
var o6 = { ...nullAndUndefinedUnion, ...nullAndUndefinedUnion };
|
||||
var o6 = { ...nullAndUndefinedUnion };
|
||||
@@ -1,20 +1,20 @@
|
||||
interface A {
|
||||
name();
|
||||
prop();
|
||||
}
|
||||
class B {
|
||||
public name() { }
|
||||
public prop() { }
|
||||
}
|
||||
class C {
|
||||
public static name() { }
|
||||
public static prop() { }
|
||||
}
|
||||
|
||||
var a: A = new B();
|
||||
a = new C(); // error name is missing
|
||||
a = B; // error name is missing
|
||||
a = new C(); // error prop is missing
|
||||
a = B; // error prop is missing
|
||||
a = C;
|
||||
|
||||
var b: B = new C(); // error name is missing
|
||||
b = B; // error name is missing
|
||||
var b: B = new C(); // error prop is missing
|
||||
b = B; // error prop is missing
|
||||
b = C;
|
||||
b = a;
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
class Base {
|
||||
protected constructor() { }
|
||||
public instance1 = new Base(); // allowed
|
||||
}
|
||||
|
||||
class Subclass extends Base {
|
||||
public instance1_1 = new Base(); // allowed
|
||||
public instance1_2 = new Subclass(); // allowed
|
||||
}
|
||||
|
||||
class SubclassOfSubclass extends Subclass {
|
||||
public instance2_1 = new Base(); // allowed
|
||||
public instance2_2 = new Subclass(); // allowed
|
||||
public instance2_3 = new SubclassOfSubclass(); // allowed
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
class A {
|
||||
constructor(f: string) {
|
||||
}
|
||||
public blah(): string { return ""; }
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
constructor() {
|
||||
super(super.blah())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// @module: system
|
||||
export const test = "TEST";
|
||||
|
||||
//some comment
|
||||
@@ -1,7 +1,6 @@
|
||||
class A<T extends T> {
|
||||
foo() {
|
||||
var x: T;
|
||||
// no error expected below this line
|
||||
var a = x.foo();
|
||||
var b = new x(123);
|
||||
var c = x[1];
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
// @strictNullChecks: true
|
||||
|
||||
let a: number;
|
||||
let b: typeof a;
|
||||
@@ -0,0 +1,6 @@
|
||||
type A = | string;
|
||||
type B =
|
||||
| { type: "INCREMENT" }
|
||||
| { type: "DECREMENT" };
|
||||
|
||||
type C = [| 0 | 1, | "foo" | "bar"];
|
||||
@@ -0,0 +1,14 @@
|
||||
// @noImplicitReferences: true
|
||||
// This tests that augmenting an untyped module is forbidden even in an ambient context. Contrast with `moduleAugmentationInDependency.ts`.
|
||||
|
||||
// @Filename: /node_modules/augmenter/index.d.ts
|
||||
declare module "js" {
|
||||
export const j: number;
|
||||
}
|
||||
export {};
|
||||
|
||||
// @Filename: /node_modules/js/index.js
|
||||
This file is not processed.
|
||||
|
||||
// @Filename: /a.ts
|
||||
import { } from "augmenter";
|
||||
@@ -0,0 +1,31 @@
|
||||
//@noUnusedLocals:true
|
||||
|
||||
declare var console: { log(a: any): void };
|
||||
|
||||
function one() {
|
||||
const foo = { a: 1, b: 2 };
|
||||
// 'a' is declared but never used
|
||||
const {a, ...bar} = foo;
|
||||
console.log(bar);
|
||||
}
|
||||
|
||||
function two() {
|
||||
const foo = { a: 1, b: 2 };
|
||||
// '_' is declared but never used
|
||||
const {a: _, ...bar} = foo;
|
||||
console.log(bar);
|
||||
}
|
||||
|
||||
function three() {
|
||||
const foo = { a: 1, b: 2 };
|
||||
// 'a' is declared but never used
|
||||
const {a, ...bar} = foo; // bar should be unused
|
||||
//console.log(bar);
|
||||
}
|
||||
|
||||
function four() {
|
||||
const foo = { a: 1, b: 2 };
|
||||
// '_' is declared but never used
|
||||
const {a: _, ...bar} = foo; // bar should be unused
|
||||
//console.log(bar);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
//@noUnusedLocals:true
|
||||
|
||||
declare let props: any;
|
||||
const {
|
||||
children, // here!
|
||||
active: _a, // here!
|
||||
...rest,
|
||||
} = props;
|
||||
|
||||
function foo() {
|
||||
const {
|
||||
children,
|
||||
active: _a,
|
||||
...rest,
|
||||
} = props;
|
||||
}
|
||||
|
||||
export const asdf = 123;
|
||||
@@ -0,0 +1,7 @@
|
||||
// @target: es2017
|
||||
// @strictNullChecks: true
|
||||
interface A extends Promise<string> {}
|
||||
declare var a: A;
|
||||
async function f() {
|
||||
await a;
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// @target: es5
|
||||
|
||||
abstract class A {
|
||||
abstract get a();
|
||||
abstract get aa() { return 1; } // error
|
||||
abstract set b(x: string);
|
||||
abstract set bb(x: string) {} // error
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
class B {
|
||||
constructor(x?: string) {}
|
||||
x(): string { return ""; }
|
||||
}
|
||||
class C1 extends B {
|
||||
constructor() {
|
||||
super.x();
|
||||
super();
|
||||
}
|
||||
}
|
||||
class C2 extends B {
|
||||
constructor() {
|
||||
super(super.x());
|
||||
}
|
||||
}
|
||||
+192
@@ -0,0 +1,192 @@
|
||||
// @target: es5
|
||||
// name
|
||||
class StaticName {
|
||||
static name: number; // error
|
||||
name: string; // ok
|
||||
}
|
||||
|
||||
class StaticNameFn {
|
||||
static name() {} // error
|
||||
name() {} // ok
|
||||
}
|
||||
|
||||
// length
|
||||
class StaticLength {
|
||||
static length: number; // error
|
||||
length: string; // ok
|
||||
}
|
||||
|
||||
class StaticLengthFn {
|
||||
static length() {} // error
|
||||
length() {} // ok
|
||||
}
|
||||
|
||||
// prototype
|
||||
class StaticPrototype {
|
||||
static prototype: number; // error
|
||||
prototype: string; // ok
|
||||
}
|
||||
|
||||
class StaticPrototypeFn {
|
||||
static prototype() {} // error
|
||||
prototype() {} // ok
|
||||
}
|
||||
|
||||
// caller
|
||||
class StaticCaller {
|
||||
static caller: number; // error
|
||||
caller: string; // ok
|
||||
}
|
||||
|
||||
class StaticCallerFn {
|
||||
static caller() {} // error
|
||||
caller() {} // ok
|
||||
}
|
||||
|
||||
// arguments
|
||||
class StaticArguments {
|
||||
static arguments: number; // error
|
||||
arguments: string; // ok
|
||||
}
|
||||
|
||||
class StaticArgumentsFn {
|
||||
static arguments() {} // error
|
||||
arguments() {} // ok
|
||||
}
|
||||
|
||||
|
||||
|
||||
// === Static properties on anonymous classes ===
|
||||
|
||||
// name
|
||||
var StaticName_Anonymous = class {
|
||||
static name: number; // error
|
||||
name: string; // ok
|
||||
}
|
||||
|
||||
var StaticNameFn_Anonymous = class {
|
||||
static name() {} // error
|
||||
name() {} // ok
|
||||
}
|
||||
|
||||
// length
|
||||
var StaticLength_Anonymous = class {
|
||||
static length: number; // error
|
||||
length: string; // ok
|
||||
}
|
||||
|
||||
var StaticLengthFn_Anonymous = class {
|
||||
static length() {} // error
|
||||
length() {} // ok
|
||||
}
|
||||
|
||||
// prototype
|
||||
var StaticPrototype_Anonymous = class {
|
||||
static prototype: number; // error
|
||||
prototype: string; // ok
|
||||
}
|
||||
|
||||
var StaticPrototypeFn_Anonymous = class {
|
||||
static prototype() {} // error
|
||||
prototype() {} // ok
|
||||
}
|
||||
|
||||
// caller
|
||||
var StaticCaller_Anonymous = class {
|
||||
static caller: number; // error
|
||||
caller: string; // ok
|
||||
}
|
||||
|
||||
var StaticCallerFn_Anonymous = class {
|
||||
static caller() {} // error
|
||||
caller() {} // ok
|
||||
}
|
||||
|
||||
// arguments
|
||||
var StaticArguments_Anonymous = class {
|
||||
static arguments: number; // error
|
||||
arguments: string; // ok
|
||||
}
|
||||
|
||||
var StaticArgumentsFn_Anonymous = class {
|
||||
static arguments() {} // error
|
||||
arguments() {} // ok
|
||||
}
|
||||
|
||||
|
||||
// === Static properties on default exported classes ===
|
||||
|
||||
// name
|
||||
module TestOnDefaultExportedClass_1 {
|
||||
class StaticName {
|
||||
static name: number; // error
|
||||
name: string; // ok
|
||||
}
|
||||
}
|
||||
|
||||
module TestOnDefaultExportedClass_2 {
|
||||
class StaticNameFn {
|
||||
static name() {} // error
|
||||
name() {} // ok
|
||||
}
|
||||
}
|
||||
|
||||
// length
|
||||
module TestOnDefaultExportedClass_3 {
|
||||
export default class StaticLength {
|
||||
static length: number; // error
|
||||
length: string; // ok
|
||||
}
|
||||
}
|
||||
|
||||
module TestOnDefaultExportedClass_4 {
|
||||
export default class StaticLengthFn {
|
||||
static length() {} // error
|
||||
length() {} // ok
|
||||
}
|
||||
}
|
||||
|
||||
// prototype
|
||||
module TestOnDefaultExportedClass_5 {
|
||||
export default class StaticPrototype {
|
||||
static prototype: number; // error
|
||||
prototype: string; // ok
|
||||
}
|
||||
}
|
||||
|
||||
module TestOnDefaultExportedClass_6 {
|
||||
export default class StaticPrototypeFn {
|
||||
static prototype() {} // error
|
||||
prototype() {} // ok
|
||||
}
|
||||
}
|
||||
|
||||
// caller
|
||||
module TestOnDefaultExportedClass_7 {
|
||||
export default class StaticCaller {
|
||||
static caller: number; // error
|
||||
caller: string; // ok
|
||||
}
|
||||
}
|
||||
|
||||
module TestOnDefaultExportedClass_8 {
|
||||
export default class StaticCallerFn {
|
||||
static caller() {} // error
|
||||
caller() {} // ok
|
||||
}
|
||||
}
|
||||
|
||||
// arguments
|
||||
module TestOnDefaultExportedClass_9 {
|
||||
export default class StaticArguments {
|
||||
static arguments: number; // error
|
||||
arguments: string; // ok
|
||||
}
|
||||
}
|
||||
|
||||
module TestOnDefaultExportedClass_10 {
|
||||
export default class StaticArgumentsFn {
|
||||
static arguments() {} // error
|
||||
arguments() {} // ok
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
|
||||
//@Filename: decl.d.ts
|
||||
// name
|
||||
declare class StaticName {
|
||||
static name: number; // ok
|
||||
name: string; // ok
|
||||
}
|
||||
|
||||
declare class StaticNameFn {
|
||||
static name(): string; // ok
|
||||
name(): string; // ok
|
||||
}
|
||||
|
||||
// length
|
||||
declare class StaticLength {
|
||||
static length: number; // ok
|
||||
length: string; // ok
|
||||
}
|
||||
|
||||
declare class StaticLengthFn {
|
||||
static length(): number; // ok
|
||||
length(): number; // ok
|
||||
}
|
||||
|
||||
// prototype
|
||||
declare class StaticPrototype {
|
||||
static prototype: number; // ok
|
||||
prototype: string; // ok
|
||||
}
|
||||
|
||||
declare class StaticPrototypeFn {
|
||||
static prototype: any; // ok
|
||||
prototype(): any; // ok
|
||||
}
|
||||
|
||||
// caller
|
||||
declare class StaticCaller {
|
||||
static caller: number; // ok
|
||||
caller: string; // ok
|
||||
}
|
||||
|
||||
declare class StaticCallerFn {
|
||||
static caller(): any; // ok
|
||||
caller(): any; // ok
|
||||
}
|
||||
|
||||
// arguments
|
||||
declare class StaticArguments {
|
||||
static arguments: number; // ok
|
||||
arguments: string; // ok
|
||||
}
|
||||
|
||||
declare class StaticArgumentsFn {
|
||||
static arguments(): any; // ok
|
||||
arguments(): any; // ok
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// @target:es5
|
||||
// @experimentaldecorators: true
|
||||
declare function dec1<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
|
||||
declare function dec2<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
|
||||
|
||||
class A {
|
||||
@dec1 get x() { return 0; }
|
||||
set x(value: number) { }
|
||||
}
|
||||
|
||||
class B {
|
||||
get x() { return 0; }
|
||||
@dec2 set x(value: number) { }
|
||||
}
|
||||
|
||||
class C {
|
||||
@dec1 set x(value: number) { }
|
||||
get x() { return 0; }
|
||||
}
|
||||
|
||||
class D {
|
||||
set x(value: number) { }
|
||||
@dec2 get x() { return 0; }
|
||||
}
|
||||
|
||||
class E {
|
||||
@dec1 get x() { return 0; }
|
||||
@dec2 set x(value: number) { }
|
||||
}
|
||||
|
||||
class F {
|
||||
@dec1 set x(value: number) { }
|
||||
@dec2 get x() { return 0; }
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// @target:es5
|
||||
// @experimentaldecorators: true
|
||||
// @emitdecoratormetadata: true
|
||||
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
|
||||
|
||||
class A {
|
||||
@dec get x() { return 0; }
|
||||
set x(value: number) { }
|
||||
}
|
||||
|
||||
class B {
|
||||
get x() { return 0; }
|
||||
@dec set x(value: number) { }
|
||||
}
|
||||
|
||||
class C {
|
||||
@dec set x(value: number) { }
|
||||
get x() { return 0; }
|
||||
}
|
||||
|
||||
class D {
|
||||
set x(value: number) { }
|
||||
@dec get x() { return 0; }
|
||||
}
|
||||
|
||||
class E {
|
||||
@dec get x() { return 0; }
|
||||
}
|
||||
|
||||
class F {
|
||||
@dec set x(value: number) { }
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// @target: es5
|
||||
// @module: commonjs
|
||||
// @experimentaldecorators: true
|
||||
// @emitdecoratormetadata: true
|
||||
declare var dec: any;
|
||||
|
||||
@dec
|
||||
class A {
|
||||
}
|
||||
|
||||
@dec
|
||||
class B {
|
||||
constructor(x: number) {}
|
||||
}
|
||||
|
||||
@dec
|
||||
class C extends A {
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
const [a, b = a] = [1]; // ok
|
||||
const [c, d = c, e = e] = [1]; // error for e = e
|
||||
const [f, g = f, h = i, i = f] = [1]; // error for h = i
|
||||
|
||||
(function ([a, b = a]) { // ok
|
||||
})([1]);
|
||||
(function ([c, d = c, e = e]) { // error for e = e
|
||||
})([1]);
|
||||
(function ([f, g = f, h = i, i = f]) { // error for h = i
|
||||
})([1])
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
const {
|
||||
a = 1,
|
||||
b = 2,
|
||||
c = b, // ok
|
||||
d = a, // ok
|
||||
e = f, // error
|
||||
f = f // error
|
||||
} = { } as any;
|
||||
@@ -0,0 +1,25 @@
|
||||
// @target: es5
|
||||
const a = new.target;
|
||||
const b = () => new.target;
|
||||
|
||||
class C {
|
||||
[new.target]() { }
|
||||
c() { return new.target; }
|
||||
get d() { return new.target; }
|
||||
set e(_) { _ = new.target; }
|
||||
f = () => new.target;
|
||||
|
||||
static [new.target]() { }
|
||||
static g() { return new.target; }
|
||||
static get h() { return new.target; }
|
||||
static set i(_) { _ = new.target; }
|
||||
static j = () => new.target;
|
||||
}
|
||||
|
||||
const O = {
|
||||
[new.target]: undefined,
|
||||
k() { return new.target; },
|
||||
get l() { return new.target; },
|
||||
set m(_) { _ = new.target; },
|
||||
n: new.target,
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
// @target: es6
|
||||
const a = new.target;
|
||||
const b = () => new.target;
|
||||
|
||||
class C {
|
||||
[new.target]() { }
|
||||
c() { return new.target; }
|
||||
get d() { return new.target; }
|
||||
set e(_) { _ = new.target; }
|
||||
f = () => new.target;
|
||||
|
||||
static [new.target]() { }
|
||||
static g() { return new.target; }
|
||||
static get h() { return new.target; }
|
||||
static set i(_) { _ = new.target; }
|
||||
static j = () => new.target;
|
||||
}
|
||||
|
||||
const O = {
|
||||
[new.target]: undefined,
|
||||
k() { return new.target; },
|
||||
get l() { return new.target; },
|
||||
set m(_) { _ = new.target; },
|
||||
n: new.target,
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
// @target: es5
|
||||
class A {
|
||||
constructor() {
|
||||
const a = new.target;
|
||||
const b = () => new.target;
|
||||
}
|
||||
static c = function () { return new.target; }
|
||||
d = function () { return new.target; }
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
constructor() {
|
||||
super();
|
||||
const e = new.target;
|
||||
const f = () => new.target;
|
||||
}
|
||||
}
|
||||
|
||||
function f1() {
|
||||
const g = new.target;
|
||||
const h = () => new.target;
|
||||
}
|
||||
|
||||
const f2 = function () {
|
||||
const i = new.target;
|
||||
const j = () => new.target;
|
||||
}
|
||||
|
||||
const O = {
|
||||
k: function () { return new.target; }
|
||||
};
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
// @target: es6
|
||||
class A {
|
||||
constructor() {
|
||||
const a = new.target;
|
||||
const b = () => new.target;
|
||||
}
|
||||
static c = function () { return new.target; }
|
||||
d = function () { return new.target; }
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
constructor() {
|
||||
super();
|
||||
const e = new.target;
|
||||
const f = () => new.target;
|
||||
}
|
||||
}
|
||||
|
||||
function f1() {
|
||||
const g = new.target;
|
||||
const h = () => new.target;
|
||||
}
|
||||
|
||||
const f2 = function () {
|
||||
const i = new.target;
|
||||
const j = () => new.target;
|
||||
}
|
||||
|
||||
const O = {
|
||||
k: function () { return new.target; }
|
||||
};
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
declare class StaticToString {
|
||||
static toString(): void;
|
||||
}
|
||||
|
||||
function foo(staticToString: StaticToString) {
|
||||
return staticToString instanceof StaticToString;
|
||||
}
|
||||
|
||||
declare class StaticToNumber {
|
||||
static toNumber(): void;
|
||||
}
|
||||
function bar(staticToNumber: StaticToNumber) {
|
||||
return staticToNumber instanceof StaticToNumber;
|
||||
}
|
||||
|
||||
declare class NormalToString {
|
||||
toString(): void;
|
||||
}
|
||||
function baz(normal: NormalToString) {
|
||||
return normal instanceof NormalToString;
|
||||
}
|
||||
@@ -27,3 +27,6 @@
|
||||
// contextually typed parameters.
|
||||
let twelve = (f => f(12))(i => i);
|
||||
let eleven = (o => o.a(11))({ a: function(n) { return n; } });
|
||||
// missing arguments
|
||||
(function(x, undefined) { return x; })(42);
|
||||
((x, y, z) => 42)();
|
||||
@@ -0,0 +1,33 @@
|
||||
// @strictNullChecks: true
|
||||
// arrow
|
||||
(jake => { })("build");
|
||||
// function expression
|
||||
(function (cats) { })("lol");
|
||||
// Lots of Irritating Superfluous Parentheses
|
||||
(function (x) { } ("!"));
|
||||
((((function (y) { }))))("-");
|
||||
// multiple arguments
|
||||
((a, b, c) => { })("foo", 101, false);
|
||||
// default parameters
|
||||
((m = 10) => m + 1)(12);
|
||||
((n = 10) => n + 1)();
|
||||
// optional parameters
|
||||
((j?) => j + 1)(12);
|
||||
((k?) => k + 1)();
|
||||
((l, o?) => l + o)(12); // o should be any
|
||||
// rest parameters
|
||||
((...numbers) => numbers.every(n => n > 0))(5,6,7);
|
||||
((...mixed) => mixed.every(n => !!n))(5,'oops','oh no');
|
||||
((...noNumbers) => noNumbers.some(n => n > 0))();
|
||||
((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10);
|
||||
// destructuring parameters (with defaults too!)
|
||||
(({ q }) => q)({ q : 13 });
|
||||
(({ p = 14 }) => p)({ p : 15 });
|
||||
(({ r = 17 } = { r: 18 }) => r)({r : 19});
|
||||
(({ u = 22 } = { u: 23 }) => u)();
|
||||
// contextually typed parameters.
|
||||
let twelve = (f => f(12))(i => i);
|
||||
let eleven = (o => o.a(11))({ a: function(n) { return n; } });
|
||||
// missing arguments
|
||||
(function(x, undefined) { return x; })(42);
|
||||
((x, y, z) => 42)();
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
interface Flags { [name: string]: boolean };
|
||||
let flags: Flags;
|
||||
flags.b;
|
||||
flags.f;
|
||||
flags.isNotNecessarilyNeverFalse;
|
||||
flags['this is fine'];
|
||||
|
||||
interface Empty { }
|
||||
let empty: Empty;
|
||||
empty.nope;
|
||||
empty["that's ok"];
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// @noImplicitAny: true
|
||||
interface Flags { [name: string]: boolean }
|
||||
let flags: Flags;
|
||||
flags.b;
|
||||
flags.f;
|
||||
flags.isNotNecessarilyNeverFalse;
|
||||
flags['this is fine'];
|
||||
|
||||
interface Empty { }
|
||||
let empty: Empty;
|
||||
empty.nope;
|
||||
empty["not allowed either"];
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
// @strictNullChecks: true
|
||||
|
||||
type T1 = { a: number };
|
||||
type T2 = T1 & { b: number };
|
||||
type T3 = () => void;
|
||||
type T4 = new () => { a: number };
|
||||
type T5 = number[];
|
||||
type T6 = [string, number];
|
||||
type T7 = { [P in 'a' | 'b' | 'c']: string };
|
||||
|
||||
interface I1 extends T1 { x: string }
|
||||
interface I2 extends T2 { x: string }
|
||||
interface I3 extends T3 { x: string }
|
||||
interface I4 extends T4 { x: string }
|
||||
interface I5 extends T5 { x: string }
|
||||
interface I6 extends T6 { x: string }
|
||||
interface I7 extends T7 { x: string }
|
||||
|
||||
type Constructor<T> = new () => T;
|
||||
declare function Constructor<T>(): Constructor<T>;
|
||||
|
||||
class C1 extends Constructor<I1>() { x: string }
|
||||
class C2 extends Constructor<I2>() { x: string }
|
||||
class C3 extends Constructor<I3>() { x: string }
|
||||
class C4 extends Constructor<I4>() { x: string }
|
||||
class C5 extends Constructor<I5>() { x: string }
|
||||
class C6 extends Constructor<I6>() { x: string }
|
||||
class C7 extends Constructor<I7>() { x: string }
|
||||
|
||||
declare function fx(x: string): string;
|
||||
declare class CX { a: number }
|
||||
declare enum EX { A, B, C }
|
||||
declare namespace NX { export const a = 1 }
|
||||
|
||||
type T10 = typeof fx;
|
||||
type T11 = typeof CX;
|
||||
type T12 = typeof EX;
|
||||
type T13 = typeof NX;
|
||||
|
||||
interface I10 extends T10 { x: string }
|
||||
interface I11 extends T11 { x: string }
|
||||
interface I12 extends T12 { x: string }
|
||||
interface I13 extends T13 { x: string }
|
||||
|
||||
type Identifiable<T> = { _id: string } & T;
|
||||
|
||||
interface I20 extends Partial<T1> { x: string }
|
||||
interface I21 extends Readonly<T1> { x: string }
|
||||
interface I22 extends Identifiable<T1> { x: string }
|
||||
interface I23 extends Identifiable<T1 & { b: number}> { x: string }
|
||||
|
||||
class C20 extends Constructor<Partial<T1>>() { x: string }
|
||||
class C21 extends Constructor<Readonly<T1>>() { x: string }
|
||||
class C22 extends Constructor<Identifiable<T1>>() { x: string }
|
||||
class C23 extends Constructor<Identifiable<T1 & { b: number}>>() { x: string }
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
// @strictNullChecks: true
|
||||
|
||||
type T1 = { a: number };
|
||||
type T2 = T1 & { b: number };
|
||||
type T3 = number[];
|
||||
type T4 = [string, number];
|
||||
type T5 = { [P in 'a' | 'b' | 'c']: string };
|
||||
|
||||
interface I1 extends T1 { a: string }
|
||||
interface I2 extends T2 { b: string }
|
||||
interface I3 extends T3 { length: string }
|
||||
interface I4 extends T4 { 0: number }
|
||||
interface I5 extends T5 { c: number }
|
||||
|
||||
type Constructor<T> = new () => T;
|
||||
declare function Constructor<T>(): Constructor<T>;
|
||||
|
||||
class C1 extends Constructor<T1>() { a: string }
|
||||
class C2 extends Constructor<T2>() { b: string }
|
||||
class C3 extends Constructor<T3>() { length: string }
|
||||
class C4 extends Constructor<T4>() { 0: number }
|
||||
class C5 extends Constructor<T5>() { c: number }
|
||||
|
||||
declare class CX { static a: string }
|
||||
declare enum EX { A, B, C }
|
||||
declare namespace NX { export const a = "hello" }
|
||||
|
||||
type TCX = typeof CX;
|
||||
type TEX = typeof EX;
|
||||
type TNX = typeof NX;
|
||||
|
||||
interface I10 extends TCX { a: number }
|
||||
interface I11 extends TEX { C: string }
|
||||
interface I12 extends TNX { a: number }
|
||||
interface I14 extends TCX { [x: string]: number }
|
||||
interface I15 extends TEX { [x: string]: number }
|
||||
interface I16 extends TNX { [x: string]: number }
|
||||
|
||||
type Identifiable<T> = { _id: string } & T;
|
||||
|
||||
interface I20 extends Partial<T1> { a: string }
|
||||
interface I21 extends Readonly<T1> { a: string }
|
||||
interface I22 extends Identifiable<T1> { a: string }
|
||||
interface I23 extends Identifiable<T1 & { b: number}> { a: string }
|
||||
|
||||
type U = { a: number } | { b: string };
|
||||
|
||||
interface I30 extends U { x: string }
|
||||
interface I31<T> extends T { x: string }
|
||||
@@ -42,7 +42,7 @@ var p = 0;
|
||||
<div>
|
||||
</div>;
|
||||
|
||||
// Emit "foo" + ' ' + "bar"
|
||||
// Emit "foo bar"
|
||||
<div>
|
||||
|
||||
foo
|
||||
@@ -51,3 +51,15 @@ var p = 0;
|
||||
|
||||
</div>;
|
||||
|
||||
// Emit "hello\\ world"
|
||||
<div>
|
||||
|
||||
hello\
|
||||
|
||||
world
|
||||
</div>;
|
||||
|
||||
// Emit " a b c d "
|
||||
<div> a
|
||||
b c
|
||||
d </div>;
|
||||
@@ -0,0 +1,27 @@
|
||||
//@jsx: preserve
|
||||
|
||||
declare module JSX {
|
||||
interface Element { }
|
||||
interface IntrinsicElements {
|
||||
[s: string]: any;
|
||||
}
|
||||
}
|
||||
declare var React: any;
|
||||
|
||||
interface TodoProp {
|
||||
id: number;
|
||||
todo: string;
|
||||
}
|
||||
interface TodoListProps {
|
||||
todos: TodoProp[];
|
||||
}
|
||||
function Todo(prop: { key: number, todo: string }) {
|
||||
return <div>{prop.key.toString() + prop.todo}</div>;
|
||||
}
|
||||
function TodoList({ todos }: TodoListProps) {
|
||||
return <div>
|
||||
{...todos.map(todo => <Todo key={todo.id} todo={todo.todo}/>)}
|
||||
</div>;
|
||||
}
|
||||
let x: TodoListProps;
|
||||
<TodoList {...x}/>
|
||||
@@ -0,0 +1,32 @@
|
||||
// @jsx: react
|
||||
declare module JSX {
|
||||
interface Element { }
|
||||
interface IntrinsicElements {
|
||||
[s: string]: any;
|
||||
}
|
||||
}
|
||||
declare var React: any;
|
||||
|
||||
interface TodoProp {
|
||||
id: number;
|
||||
todo: string;
|
||||
}
|
||||
interface TodoListProps {
|
||||
todos: TodoProp[];
|
||||
}
|
||||
function Todo(prop: { key: number, todo: string }) {
|
||||
return <div>{prop.key.toString() + prop.todo}</div>;
|
||||
}
|
||||
function TodoList({ todos }: TodoListProps) {
|
||||
return <div>
|
||||
{...<Todo key={todos[0].id} todo={todos[0].todo} />}
|
||||
</div>;
|
||||
}
|
||||
function TodoListNoError({ todos }: TodoListProps) {
|
||||
// any is not checked
|
||||
return <div>
|
||||
{...(<Todo key={todos[0].id} todo={todos[0].todo} /> as any)}
|
||||
</div>;
|
||||
}
|
||||
let x: TodoListProps;
|
||||
<TodoList {...x}/>
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
namespace Foo {
|
||||
export default foo;
|
||||
}
|
||||
|
||||
module Bar {
|
||||
export default bar;
|
||||
}
|
||||
Loaded 100 of 2256 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user