mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'noParentNodesInEmitter' into transformPerf
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
var x = {one: 1};
|
||||
var y: {[index:string]: any};
|
||||
|
||||
x = y;
|
||||
y = x;
|
||||
var x = { one: 1 };
|
||||
var y: { [index: string]: any };
|
||||
var z: { [index: number]: any };
|
||||
x = y; // Error
|
||||
y = x; // Ok because index signature type is any
|
||||
x = z; // Error
|
||||
z = x; // Ok because index signature type is any
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
const enum E { A, B, C }
|
||||
|
||||
function foo<T extends number>(x: T) {
|
||||
var y: number = x; // Ok
|
||||
}
|
||||
|
||||
foo(5);
|
||||
foo(E.A);
|
||||
|
||||
class A { a }
|
||||
class B { b }
|
||||
|
||||
function bar<T extends A | B>(x: T) {
|
||||
var y: A | B = x; // Ok
|
||||
}
|
||||
|
||||
bar(new A);
|
||||
bar(new B);
|
||||
@@ -0,0 +1,12 @@
|
||||
class C extends null {
|
||||
constructor() {
|
||||
super();
|
||||
return Object.create(null);
|
||||
}
|
||||
}
|
||||
|
||||
class D extends null {
|
||||
constructor() {
|
||||
return Object.create(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
function foo(/*c1*/ x: any) { }
|
||||
foo(/*c2*/ 1);
|
||||
foo(/*c3*/ function () { });
|
||||
foo(
|
||||
/*c4*/
|
||||
() => { });
|
||||
foo(
|
||||
/*c5*/
|
||||
/*c6*/
|
||||
() => { });
|
||||
foo(/*c7*/
|
||||
() => { });
|
||||
foo(
|
||||
/*c7*/
|
||||
/*c8*/() => { });
|
||||
@@ -0,0 +1,10 @@
|
||||
function foo(/*c1*/ x: any, /*d1*/ y: any,/*e1*/w?: any) { }
|
||||
var a, b: any;
|
||||
foo(/*c2*/ 1, /*d2*/ 1 + 2, /*e1*/ a + b);
|
||||
foo(/*c3*/ function () { }, /*d2*/() => { }, /*e2*/ a + /*e3*/ b);
|
||||
foo(/*c3*/ function () { }, /*d3*/() => { }, /*e3*/(a + b));
|
||||
foo(
|
||||
/*c4*/ function () { },
|
||||
/*d4*/() => { },
|
||||
/*e4*/
|
||||
/*e5*/ "hello");
|
||||
@@ -0,0 +1,13 @@
|
||||
var resolve = {
|
||||
id: /*! @ngInject */ (details: any) => details.id,
|
||||
id1: /* c1 */ "hello",
|
||||
id2:
|
||||
/*! @ngInject */ (details: any) => details.id,
|
||||
id3:
|
||||
/*! @ngInject */
|
||||
(details: any) => details.id,
|
||||
id4:
|
||||
/*! @ngInject */
|
||||
/* C2 */
|
||||
(details: any) => details.id,
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
// @target: ES5
|
||||
// @module: commonjs
|
||||
// @declaration: true
|
||||
// @filename: 10_lib.ts
|
||||
|
||||
export function Foo() {}
|
||||
|
||||
// @filename: main.ts
|
||||
import { Foo } from './10_lib';
|
||||
|
||||
Foo();
|
||||
@@ -0,0 +1,22 @@
|
||||
// @comments: false
|
||||
const enum Foo {
|
||||
X = 100,
|
||||
Y = 0.5,
|
||||
Z = 2.,
|
||||
A = -1,
|
||||
B = -1.5,
|
||||
C = -1.
|
||||
}
|
||||
|
||||
let x0 = Foo.X.toString();
|
||||
let x1 = Foo["X"].toString();
|
||||
let y0 = Foo.Y.toString();
|
||||
let y1 = Foo["Y"].toString();
|
||||
let z0 = Foo.Z.toString();
|
||||
let z1 = Foo["Z"].toString();
|
||||
let a0 = Foo.A.toString();
|
||||
let a1 = Foo["A"].toString();
|
||||
let b0 = Foo.B.toString();
|
||||
let b1 = Foo["B"].toString();
|
||||
let c0 = Foo.C.toString();
|
||||
let c1 = Foo["C"].toString();
|
||||
@@ -0,0 +1,22 @@
|
||||
// @comments: true
|
||||
const enum Foo {
|
||||
X = 100,
|
||||
Y = 0.5,
|
||||
Z = 2.,
|
||||
A = -1,
|
||||
B = -1.5,
|
||||
C = -1.
|
||||
}
|
||||
|
||||
let x0 = Foo.X.toString();
|
||||
let x1 = Foo["X"].toString();
|
||||
let y0 = Foo.Y.toString();
|
||||
let y1 = Foo["Y"].toString();
|
||||
let z0 = Foo.Z.toString();
|
||||
let z1 = Foo["Z"].toString();
|
||||
let a0 = Foo.A.toString();
|
||||
let a1 = Foo["A"].toString();
|
||||
let b0 = Foo.B.toString();
|
||||
let b1 = Foo["B"].toString();
|
||||
let c0 = Foo.C.toString();
|
||||
let c1 = Foo["C"].toString();
|
||||
@@ -0,0 +1,5 @@
|
||||
// @target: ES5
|
||||
// @declaration: true
|
||||
|
||||
class ExtendsNull extends null {
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// @target: es5
|
||||
// @module: commonjs
|
||||
// @declaration: true
|
||||
|
||||
// @filename: utils.ts
|
||||
export function foo() { }
|
||||
export function bar() { }
|
||||
export interface Buzz { }
|
||||
|
||||
// @filename: index.ts
|
||||
import {foo} from "utils";
|
||||
export = foo;
|
||||
@@ -0,0 +1,15 @@
|
||||
// @target: es5
|
||||
// @module: commonjs
|
||||
// @declaration: true
|
||||
|
||||
// @filename: utils.ts
|
||||
export function foo() { }
|
||||
export function bar() { }
|
||||
export interface Buzz { }
|
||||
|
||||
// @filename: index.ts
|
||||
import {foo, bar, Buzz} from "utils";
|
||||
|
||||
foo();
|
||||
let obj: Buzz;
|
||||
export {bar};
|
||||
@@ -0,0 +1,17 @@
|
||||
// @noemithelpers: true
|
||||
// @experimentaldecorators: true
|
||||
// @emitdecoratormetadata: true
|
||||
// @target: es5
|
||||
|
||||
declare var decorator: any;
|
||||
|
||||
class MyClass {
|
||||
constructor(test: string, test2: number) {
|
||||
|
||||
}
|
||||
|
||||
@decorator
|
||||
doSomething() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// @noemithelpers: true
|
||||
// @experimentaldecorators: true
|
||||
// @emitdecoratormetadata: true
|
||||
// @target: es5
|
||||
// @module: commonjs
|
||||
|
||||
declare var console: {
|
||||
log(msg: string): void;
|
||||
};
|
||||
|
||||
class A {
|
||||
constructor() { console.log('new A'); }
|
||||
}
|
||||
|
||||
function decorator(target: Object, propertyKey: string) {
|
||||
}
|
||||
|
||||
export class B {
|
||||
@decorator
|
||||
x: A = new A();
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// @noemithelpers: true
|
||||
// @experimentaldecorators: true
|
||||
// @emitdecoratormetadata: true
|
||||
// @target: es5
|
||||
// @module: commonjs
|
||||
// @filename: db.ts
|
||||
export class db {
|
||||
public doSomething() {
|
||||
}
|
||||
}
|
||||
|
||||
// @filename: service.ts
|
||||
import {db} from './db';
|
||||
function someDecorator(target) {
|
||||
return target;
|
||||
}
|
||||
@someDecorator
|
||||
class MyClass {
|
||||
db: db;
|
||||
|
||||
constructor(db: db) {
|
||||
this.db = db;
|
||||
this.db.doSomething();
|
||||
}
|
||||
}
|
||||
export {MyClass};
|
||||
@@ -0,0 +1,26 @@
|
||||
// @noemithelpers: true
|
||||
// @experimentaldecorators: true
|
||||
// @emitdecoratormetadata: true
|
||||
// @target: es5
|
||||
// @module: commonjs
|
||||
// @filename: db.ts
|
||||
export class db {
|
||||
public doSomething() {
|
||||
}
|
||||
}
|
||||
|
||||
// @filename: service.ts
|
||||
import {db as Database} from './db';
|
||||
function someDecorator(target) {
|
||||
return target;
|
||||
}
|
||||
@someDecorator
|
||||
class MyClass {
|
||||
db: Database;
|
||||
|
||||
constructor(db: Database) { // no collision
|
||||
this.db = db;
|
||||
this.db.doSomething();
|
||||
}
|
||||
}
|
||||
export {MyClass};
|
||||
@@ -0,0 +1,26 @@
|
||||
// @noemithelpers: true
|
||||
// @experimentaldecorators: true
|
||||
// @emitdecoratormetadata: true
|
||||
// @target: es5
|
||||
// @module: commonjs
|
||||
// @filename: db.ts
|
||||
export class db {
|
||||
public doSomething() {
|
||||
}
|
||||
}
|
||||
|
||||
// @filename: service.ts
|
||||
import db = require('./db');
|
||||
function someDecorator(target) {
|
||||
return target;
|
||||
}
|
||||
@someDecorator
|
||||
class MyClass {
|
||||
db: db.db;
|
||||
|
||||
constructor(db: db.db) { // collision with namespace of external module db
|
||||
this.db = db;
|
||||
this.db.doSomething();
|
||||
}
|
||||
}
|
||||
export {MyClass};
|
||||
@@ -0,0 +1,26 @@
|
||||
// @noemithelpers: true
|
||||
// @experimentaldecorators: true
|
||||
// @emitdecoratormetadata: true
|
||||
// @target: es5
|
||||
// @module: commonjs
|
||||
// @filename: db.ts
|
||||
export class db {
|
||||
public doSomething() {
|
||||
}
|
||||
}
|
||||
|
||||
// @filename: service.ts
|
||||
import db from './db'; // error no default export
|
||||
function someDecorator(target) {
|
||||
return target;
|
||||
}
|
||||
@someDecorator
|
||||
class MyClass {
|
||||
db: db.db;
|
||||
|
||||
constructor(db: db.db) {
|
||||
this.db = db;
|
||||
this.db.doSomething();
|
||||
}
|
||||
}
|
||||
export {MyClass};
|
||||
@@ -0,0 +1,26 @@
|
||||
// @noemithelpers: true
|
||||
// @experimentaldecorators: true
|
||||
// @emitdecoratormetadata: true
|
||||
// @target: es5
|
||||
// @module: commonjs
|
||||
// @filename: db.ts
|
||||
export default class db {
|
||||
public doSomething() {
|
||||
}
|
||||
}
|
||||
|
||||
// @filename: service.ts
|
||||
import db from './db';
|
||||
function someDecorator(target) {
|
||||
return target;
|
||||
}
|
||||
@someDecorator
|
||||
class MyClass {
|
||||
db: db;
|
||||
|
||||
constructor(db: db) { // collision
|
||||
this.db = db;
|
||||
this.db.doSomething();
|
||||
}
|
||||
}
|
||||
export {MyClass};
|
||||
@@ -0,0 +1,26 @@
|
||||
// @noemithelpers: true
|
||||
// @experimentaldecorators: true
|
||||
// @emitdecoratormetadata: true
|
||||
// @target: es5
|
||||
// @module: commonjs
|
||||
// @filename: db.ts
|
||||
export default class db {
|
||||
public doSomething() {
|
||||
}
|
||||
}
|
||||
|
||||
// @filename: service.ts
|
||||
import database from './db';
|
||||
function someDecorator(target) {
|
||||
return target;
|
||||
}
|
||||
@someDecorator
|
||||
class MyClass {
|
||||
db: database;
|
||||
|
||||
constructor(db: database) { // no collision
|
||||
this.db = db;
|
||||
this.db.doSomething();
|
||||
}
|
||||
}
|
||||
export {MyClass};
|
||||
@@ -0,0 +1,26 @@
|
||||
// @noemithelpers: true
|
||||
// @experimentaldecorators: true
|
||||
// @emitdecoratormetadata: true
|
||||
// @target: es5
|
||||
// @module: commonjs
|
||||
// @filename: db.ts
|
||||
export default class db {
|
||||
public doSomething() {
|
||||
}
|
||||
}
|
||||
|
||||
// @filename: service.ts
|
||||
import db from './db';
|
||||
function someDecorator(target) {
|
||||
return target;
|
||||
}
|
||||
@someDecorator
|
||||
class MyClass {
|
||||
db: db.db; //error
|
||||
|
||||
constructor(db: db.db) { // error
|
||||
this.db = db;
|
||||
this.db.doSomething();
|
||||
}
|
||||
}
|
||||
export {MyClass};
|
||||
@@ -0,0 +1,26 @@
|
||||
// @noemithelpers: true
|
||||
// @experimentaldecorators: true
|
||||
// @emitdecoratormetadata: true
|
||||
// @target: es5
|
||||
// @module: commonjs
|
||||
// @filename: db.ts
|
||||
export class db {
|
||||
public doSomething() {
|
||||
}
|
||||
}
|
||||
|
||||
// @filename: service.ts
|
||||
import database = require('./db');
|
||||
function someDecorator(target) {
|
||||
return target;
|
||||
}
|
||||
@someDecorator
|
||||
class MyClass {
|
||||
db: database.db;
|
||||
|
||||
constructor(db: database.db) { // no collision
|
||||
this.db = db;
|
||||
this.db.doSomething();
|
||||
}
|
||||
}
|
||||
export {MyClass};
|
||||
@@ -0,0 +1,19 @@
|
||||
// @target: es6
|
||||
|
||||
// @filename: server.d.ts
|
||||
declare module "other" {
|
||||
export class C { }
|
||||
}
|
||||
|
||||
declare module "server" {
|
||||
import events = require("other"); // Ambient declaration, no error expected.
|
||||
|
||||
module S {
|
||||
export var a: number;
|
||||
}
|
||||
|
||||
export = S; // Ambient declaration, no error expected.
|
||||
}
|
||||
|
||||
// @filename: client.ts
|
||||
import {a} from "server";
|
||||
@@ -0,0 +1,3 @@
|
||||
//@suppressExcessPropertyErrors: true
|
||||
|
||||
var x: { a: string } = { a: "hello", b: 42 }; // No error
|
||||
@@ -3,5 +3,5 @@
|
||||
(...arg) => 103;
|
||||
(...arg:number [] = []) => 104;
|
||||
|
||||
// Non optional parameter following an optional one
|
||||
// Uninitialized parameter makes the initialized one required
|
||||
(arg1 = 1, arg2) => 1;
|
||||
@@ -0,0 +1,13 @@
|
||||
enum E1 {
|
||||
// illegal case
|
||||
// forward reference to the element of the same enum
|
||||
X = Y,
|
||||
X1 = E1["Y"],
|
||||
// forward reference to the element of the same enum
|
||||
Y = E1.Z,
|
||||
Y1 = E1["Z"]
|
||||
}
|
||||
|
||||
enum E1 {
|
||||
Z = 4
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
function f<T extends { "0": (p1: number) => number }>(p: T): T {
|
||||
return p;
|
||||
}
|
||||
|
||||
var v = f([x => x]);
|
||||
@@ -0,0 +1,5 @@
|
||||
function f<T extends [(p1: number) => number]>(p: T): T {
|
||||
return p;
|
||||
}
|
||||
|
||||
var v = f([x => x]);
|
||||
@@ -0,0 +1,5 @@
|
||||
function f<T extends ((p1: number) => number)[]>(p: T): T {
|
||||
return p;
|
||||
}
|
||||
|
||||
var v = f([x => x]);
|
||||
@@ -0,0 +1,5 @@
|
||||
function f<T extends (p1: number) => number>(p: T): T {
|
||||
return p;
|
||||
}
|
||||
|
||||
var v = f(x => x);
|
||||
@@ -0,0 +1,5 @@
|
||||
function f<T extends { q: (p1: number) => number }>(p: T): T {
|
||||
return p;
|
||||
}
|
||||
|
||||
var v = f({ q: x => x });
|
||||
@@ -0,0 +1,88 @@
|
||||
interface Base {
|
||||
foo: string|number;
|
||||
optional?: number;
|
||||
}
|
||||
|
||||
// Derived1 is assignable to, but not a subtype of, Base
|
||||
class Derived1 implements Base {
|
||||
foo: string;
|
||||
}
|
||||
// Derived2 is a subtype of Base that is not assignable to Derived1
|
||||
class Derived2 implements Base {
|
||||
foo: number;
|
||||
optional: number;
|
||||
}
|
||||
|
||||
class Animal {
|
||||
move;
|
||||
}
|
||||
class Mammal extends Animal { milk; }
|
||||
class Giraffe extends Mammal { neck; }
|
||||
|
||||
function fn1(x: Array<number>|Array<string>|boolean) {
|
||||
if(x instanceof Array) {
|
||||
// 1.5: y: Array<number>|Array<string>
|
||||
// Want: y: Array<number>|Array<string>
|
||||
let y = x;
|
||||
}
|
||||
}
|
||||
|
||||
function fn2(x: Base) {
|
||||
if(x instanceof Derived1) {
|
||||
// 1.5: y: Base
|
||||
// Want: y: Derived1
|
||||
let y = x;
|
||||
}
|
||||
}
|
||||
|
||||
function fn3(x: Base|Derived1) {
|
||||
if(x instanceof Derived2) {
|
||||
// 1.5: y: Derived2
|
||||
// Want: Derived2
|
||||
let y = x;
|
||||
}
|
||||
}
|
||||
|
||||
function fn4(x: Base|Derived2) {
|
||||
if(x instanceof Derived1) {
|
||||
// 1.5: y: {}
|
||||
// Want: Derived1
|
||||
let y = x;
|
||||
}
|
||||
}
|
||||
|
||||
function fn5(x: Derived1) {
|
||||
if(x instanceof Derived2) {
|
||||
// 1.5: y: Derived1
|
||||
// Want: ???
|
||||
let y = x;
|
||||
}
|
||||
}
|
||||
|
||||
function fn6(x: Animal|Mammal) {
|
||||
if(x instanceof Giraffe) {
|
||||
// 1.5: y: Derived1
|
||||
// Want: ???
|
||||
let y = x;
|
||||
}
|
||||
}
|
||||
|
||||
function fn7(x: Array<number>|Array<string>) {
|
||||
if(x instanceof Array) {
|
||||
// 1.5: y: Array<number>|Array<string>
|
||||
// Want: y: Array<number>|Array<string>
|
||||
let y = x;
|
||||
}
|
||||
}
|
||||
|
||||
interface Alpha { a }
|
||||
interface Beta { b }
|
||||
interface Gamma { c }
|
||||
class ABC { a; b; c; }
|
||||
function fn8(x: Alpha|Beta|Gamma) {
|
||||
if(x instanceof ABC) {
|
||||
let y = x;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
//@jsx: preserve
|
||||
var t02 = <a>{0}#</a>;
|
||||
var t03 = <a>#{0}</a>;
|
||||
var t04 = <a>#{0}#</a>;
|
||||
var t05 = <a>#<i></i></a>;
|
||||
var t06 = <a>#<i></i></a>;
|
||||
var t07 = <a>#<i>#</i></a>;
|
||||
var t08 = <a><i></i>#</a>;
|
||||
var t09 = <a>#<i></i>#</a>;
|
||||
var t10 = <a><i/>#</a>;
|
||||
var t11 = <a>#<i/></a>;
|
||||
var t12 = <a>#</a>;
|
||||
@@ -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" {
|
||||
var base: React.Component<any, {}>;
|
||||
export = base;
|
||||
}
|
||||
|
||||
//@filename: consumer.tsx
|
||||
/// <reference path="component.d.ts" />
|
||||
import BaseComponent = require('BaseComponent');
|
||||
class TestComponent extends React.Component<any, {}> {
|
||||
render() {
|
||||
return <BaseComponent />;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class George extends class { reset() { return this.y; } } {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// @module:commonjs
|
||||
// @noResolve: true
|
||||
|
||||
// @filename: a.ts
|
||||
import a = require('./b');
|
||||
|
||||
// @filename: b.ts
|
||||
export var c = '';
|
||||
@@ -0,0 +1,8 @@
|
||||
// @module: commonjs
|
||||
// @moduleResolution: node
|
||||
|
||||
// @filename: a.ts
|
||||
export var x = 1;
|
||||
|
||||
// @filename: b.ts
|
||||
import y = require("./a");
|
||||
@@ -0,0 +1,8 @@
|
||||
// @module: commonjs
|
||||
// @moduleResolution: node
|
||||
|
||||
// @filename: node_modules/a.d.ts
|
||||
export var x: number;
|
||||
|
||||
// @filename: b.ts
|
||||
import y = require("a");
|
||||
@@ -0,0 +1,8 @@
|
||||
// @module: commonjs
|
||||
// @moduleResolution: node
|
||||
|
||||
// @filename: node_modules/b/index.d.ts
|
||||
export var x: number;
|
||||
|
||||
// @filename: a.ts
|
||||
import y = require("b");
|
||||
@@ -30,8 +30,7 @@ class C1 {
|
||||
|
||||
public C1M5(C1M5A1:number,C1M5A2:number=0,C1M5A3?:number) { return C1M5A1 + C1M5A2; }
|
||||
|
||||
// Negative test
|
||||
// "Optional parameters may only be followed by other optional parameters"
|
||||
// Uninitialized parameter makes the initialized one required
|
||||
public C1M5(C1M5A1:number,C1M5A2:number=0,C1M5A3:number) { return C1M5A1 + C1M5A2; }
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// @target: ES5
|
||||
// @sourcemap: true
|
||||
// @declaration: true
|
||||
// @module: commonjs
|
||||
// @outFile: c.js
|
||||
|
||||
// @Filename: a.ts
|
||||
class A { }
|
||||
|
||||
// @Filename: b.ts
|
||||
class B { }
|
||||
@@ -0,0 +1,14 @@
|
||||
// @target: ES5
|
||||
// @sourcemap: true
|
||||
// @declaration: true
|
||||
// @module: commonjs
|
||||
// @outFile: c.js
|
||||
// @out: d.js
|
||||
|
||||
// --out and --outFile error
|
||||
|
||||
// @Filename: a.ts
|
||||
class A { }
|
||||
|
||||
// @Filename: b.ts
|
||||
class B { }
|
||||
@@ -0,0 +1,6 @@
|
||||
// @declaration: true
|
||||
|
||||
interface C {
|
||||
({p: name}): any;
|
||||
new ({p: boolean}): any;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
interface Tree1 {
|
||||
children: [Tree1, Tree2];
|
||||
}
|
||||
|
||||
interface Tree2 {
|
||||
children: [Tree2, Tree1];
|
||||
}
|
||||
|
||||
let tree1: Tree1;
|
||||
let tree2: Tree2;
|
||||
tree1 = tree2;
|
||||
tree2 = tree1;
|
||||
@@ -0,0 +1,12 @@
|
||||
interface Tree1 {
|
||||
children: [Tree1, Tree2];
|
||||
}
|
||||
|
||||
interface Tree2 {
|
||||
children: [Tree2, Tree2];
|
||||
}
|
||||
|
||||
let tree1: Tree1;
|
||||
let tree2: Tree2;
|
||||
tree1 = tree2;
|
||||
tree2 = tree1;
|
||||
@@ -0,0 +1,19 @@
|
||||
function f1(a, b = 0, c) { }
|
||||
function f2(a, b = 0, c = 0) { }
|
||||
function f3(a, b = 0, c?) { }
|
||||
function f4(a, b = 0, ...c) { }
|
||||
|
||||
f1(0, 1, 2);
|
||||
f2(0, 1, 2);
|
||||
f3(0, 1, 2);
|
||||
f4(0, 1, 2);
|
||||
|
||||
f1(0, 1);
|
||||
f2(0, 1);
|
||||
f3(0, 1);
|
||||
f4(0, 1);
|
||||
|
||||
f1(0);
|
||||
f2(0);
|
||||
f3(0);
|
||||
f4(0);
|
||||
@@ -0,0 +1,7 @@
|
||||
interface I1 {
|
||||
method();
|
||||
}
|
||||
|
||||
class C1 implements I1 {
|
||||
method(a = 0, b) { }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
//@declaration: true
|
||||
interface I1 {
|
||||
method();
|
||||
}
|
||||
|
||||
class C1 implements I1 {
|
||||
method(a = 0, b?) { }
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
//@declaration: true
|
||||
class C1 {
|
||||
method(a = 0, b) { }
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
interface bar { }
|
||||
let bar: bar;
|
||||
@@ -0,0 +1,4 @@
|
||||
interface foo { }
|
||||
interface bar { }
|
||||
let bar: bar | foo;
|
||||
let foo: bar | foo;
|
||||
@@ -0,0 +1,8 @@
|
||||
declare module foo {
|
||||
|
||||
interface Bar {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
let foo: foo.Bar;
|
||||
@@ -0,0 +1,8 @@
|
||||
declare module "punycode" {
|
||||
interface ucs2 {
|
||||
decode(string: string): string;
|
||||
encode(codePoints: number[]): string;
|
||||
}
|
||||
|
||||
export let ucs2: ucs2;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class C { }
|
||||
type baz = C;
|
||||
let baz: baz;
|
||||
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env node
|
||||
var foo = 'I wish the generated JS to be executed in node';
|
||||
@@ -0,0 +1,2 @@
|
||||
var foo = 'Shebang is only allowed on the first line';
|
||||
#!/usr/bin/env node
|
||||
@@ -0,0 +1,21 @@
|
||||
// @target: ES5
|
||||
// @sourcemap: true
|
||||
module sas.tools {
|
||||
export class Test {
|
||||
public doX(): void {
|
||||
let f: number = 2;
|
||||
switch (f) {
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
//line comment 1
|
||||
//line comment 2
|
||||
break;
|
||||
case 3:
|
||||
//a comment
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// @target: ES5
|
||||
// @sourcemap: true
|
||||
function foo(str: string, num: number): void {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* some sort of block quote
|
||||
*/
|
||||
function bar(str: string, num: number): void {
|
||||
return;
|
||||
}
|
||||
|
||||
// some sort of comment
|
||||
function baz(str: string, num: number): void {
|
||||
return;
|
||||
}
|
||||
|
||||
function qat(str: string, num: number): void {
|
||||
return;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
class A {
|
||||
}
|
||||
|
||||
class C {
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
constructor() {
|
||||
|
||||
class D extends C {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
class A {
|
||||
}
|
||||
|
||||
class C {
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
constructor() {
|
||||
|
||||
var D = class extends C {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
class A {
|
||||
foo() {
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
constructor() {
|
||||
var x = {
|
||||
x: super()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class Foo extends Bar {
|
||||
m1() {
|
||||
return super.m1();
|
||||
}
|
||||
|
||||
static m2() {
|
||||
return super.m2();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// @module: system
|
||||
// @isolatedModules: true
|
||||
|
||||
function foo() {
|
||||
return a;
|
||||
}
|
||||
|
||||
import {a} from "foo";
|
||||
export {foo}
|
||||
|
||||
var x = 1;
|
||||
export {foo as b}
|
||||
@@ -0,0 +1,34 @@
|
||||
// @module: system
|
||||
// @isolatedModules: true
|
||||
|
||||
// @filename: file1.ts
|
||||
|
||||
import * as moduleB from "./file2"
|
||||
|
||||
declare function use(v: any): void;
|
||||
|
||||
use(moduleB.value);
|
||||
use(moduleB.moduleC);
|
||||
use(moduleB.moduleCStar);
|
||||
|
||||
// @filename: file2.ts
|
||||
|
||||
import * as moduleCStar from "./file3"
|
||||
import {value2} from "./file4"
|
||||
import moduleC from "./file3"
|
||||
import {value} from "./file3"
|
||||
|
||||
export {
|
||||
moduleCStar,
|
||||
moduleC,
|
||||
value
|
||||
}
|
||||
|
||||
// @filename: file3.ts
|
||||
|
||||
export var value = "youpi";
|
||||
export default value;
|
||||
|
||||
// @filename: file4.ts
|
||||
|
||||
export var value2 = "v";
|
||||
@@ -0,0 +1,13 @@
|
||||
// @module: system
|
||||
// @isolatedModules: true
|
||||
|
||||
import * as x from "foo";
|
||||
import * as y from "bar";
|
||||
export * from "foo";
|
||||
export * from "bar"
|
||||
export {x}
|
||||
export {y}
|
||||
import {a1, b1, c1 as d1} from "foo";
|
||||
export {a2, b2, c2 as d2} from "bar";
|
||||
|
||||
x,y,a1,b1,d1;
|
||||
@@ -0,0 +1,12 @@
|
||||
// @module: system
|
||||
|
||||
// @Filename: foo.ts
|
||||
export class Foo {
|
||||
a: string;
|
||||
}
|
||||
|
||||
// @Filename: bar.ts
|
||||
import {Foo} from './foo';
|
||||
export class Bar extends Foo {
|
||||
b: string;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
declare var $q: IQService;
|
||||
|
||||
interface IQService {
|
||||
all<T1, T2, T3>(x: [IPromise<T1>, IPromise<T2>, IPromise<T3>]): IPromise<[T1, T2, T3]>;
|
||||
all<T1, T2>(x: [IPromise<T1>, IPromise<T2>]): IPromise<[T1, T2]>;
|
||||
all<T1>(x: [IPromise<T1>]): IPromise<[T1]>;
|
||||
when<T>(t?: T): IPromise<T>;
|
||||
}
|
||||
|
||||
interface IPromise<T> {
|
||||
then<TResult>(callback: (t: T) => TResult): IPromise<TResult>;
|
||||
}
|
||||
|
||||
// Implicit different types
|
||||
var a = $q.all([$q.when<string>(), $q.when<number>()]);
|
||||
|
||||
// Explicit different types
|
||||
var b = $q.all<string, number>([$q.when<string>(), $q.when<number>()]);
|
||||
|
||||
// Implicit identical types
|
||||
var c = $q.all([$q.when<string>(), $q.when<string>()]);
|
||||
@@ -0,0 +1,7 @@
|
||||
// @target: ES5
|
||||
// @module: AMD
|
||||
// @declaration: true
|
||||
|
||||
export type callback<T> = () => T;
|
||||
|
||||
export type CallbackArray<T extends callback> = () => T;
|
||||
@@ -0,0 +1,5 @@
|
||||
// @target: ES5
|
||||
// @module: AMD
|
||||
// @declaration: true
|
||||
|
||||
export type A<a> = { value: a };
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
type TreeNode = {
|
||||
name: string;
|
||||
parent: TreeNode;
|
||||
}
|
||||
|
||||
var nodes: TreeNode[];
|
||||
nodes.map(n => n.name);
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
type TreeNode = {
|
||||
name: string;
|
||||
parent: TreeNode;
|
||||
}
|
||||
|
||||
type TreeNodeMiddleman = {
|
||||
name: string;
|
||||
parent: TreeNode;
|
||||
}
|
||||
|
||||
var nodes: TreeNodeMiddleman[];
|
||||
nodes.map(n => n.name);
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
abstract class A { }
|
||||
|
||||
// var AA: typeof A;
|
||||
var AAA: new() => A;
|
||||
|
||||
// AA = A; // okay
|
||||
AAA = A; // error.
|
||||
AAA = "asdf";
|
||||
@@ -0,0 +1,10 @@
|
||||
// @module: commonjs
|
||||
// @Filename: foo1.ts
|
||||
class x{}
|
||||
|
||||
export = x;
|
||||
|
||||
// @Filename: foo2.ts
|
||||
import foo1 = require('./foo1');
|
||||
var x = foo1;
|
||||
class y extends x {}
|
||||
@@ -0,0 +1,17 @@
|
||||
// @experimentalDecorators: true
|
||||
// @emitDecoratorMetadata: true
|
||||
// @target: es5
|
||||
// @module: commonjs
|
||||
// @filename: service.ts
|
||||
export default class Service {
|
||||
}
|
||||
// @filename: component.ts
|
||||
import Service from "./service";
|
||||
|
||||
declare var decorator: any;
|
||||
|
||||
@decorator
|
||||
class MyComponent {
|
||||
constructor(public Service: Service) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// @module: commonjs
|
||||
// @target: ES5
|
||||
|
||||
// @filename: m1.ts
|
||||
export default function Decl() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
export interface Decl {
|
||||
p1: number;
|
||||
p2: number;
|
||||
}
|
||||
|
||||
export namespace Decl {
|
||||
export var x = 10;
|
||||
export var y = 20;
|
||||
|
||||
interface I {
|
||||
}
|
||||
}
|
||||
|
||||
// @filename: m2.ts
|
||||
import Entity from "m1"
|
||||
|
||||
Entity();
|
||||
|
||||
var x: Entity;
|
||||
var y: Entity.I;
|
||||
|
||||
Entity.x;
|
||||
Entity.y;
|
||||
@@ -0,0 +1,26 @@
|
||||
// @module: commonjs
|
||||
// @target: ES5
|
||||
|
||||
// @filename: m1.ts
|
||||
export default class Decl {
|
||||
}
|
||||
|
||||
export interface Decl {
|
||||
p1: number;
|
||||
p2: number;
|
||||
}
|
||||
|
||||
export namespace Decl {
|
||||
interface I {
|
||||
}
|
||||
}
|
||||
|
||||
// @filename: m2.ts
|
||||
import Entity from "m1"
|
||||
|
||||
Entity();
|
||||
|
||||
var x: Entity;
|
||||
var y: Entity.I;
|
||||
var z = new Entity();
|
||||
var sum = z.p1 + z.p2
|
||||
@@ -0,0 +1,26 @@
|
||||
// @module: commonjs
|
||||
// @target: ES5
|
||||
|
||||
// @filename: m1.ts
|
||||
export default class Decl {
|
||||
}
|
||||
|
||||
interface Decl {
|
||||
p1: number;
|
||||
p2: number;
|
||||
}
|
||||
|
||||
namespace Decl {
|
||||
interface I {
|
||||
}
|
||||
}
|
||||
|
||||
// @filename: m2.ts
|
||||
import Entity from "m1"
|
||||
|
||||
Entity();
|
||||
|
||||
var x: Entity;
|
||||
var y: Entity.I;
|
||||
var z = new Entity();
|
||||
var sum = z.p1 + z.p2
|
||||
@@ -0,0 +1,15 @@
|
||||
// @module: commonjs
|
||||
// @target: ES5
|
||||
|
||||
export default function Foo() {
|
||||
}
|
||||
|
||||
namespace Foo {
|
||||
export var x;
|
||||
}
|
||||
|
||||
interface Foo {
|
||||
}
|
||||
|
||||
export interface Foo {
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// @module: commonjs
|
||||
// @target: ES5
|
||||
|
||||
// @filename: m1.ts
|
||||
export default class foo {
|
||||
|
||||
}
|
||||
|
||||
export default function bar() {
|
||||
|
||||
}
|
||||
|
||||
var x = 10;
|
||||
export default x;
|
||||
|
||||
// @filename: m2.ts
|
||||
import Entity from "m1"
|
||||
|
||||
Entity();
|
||||
@@ -0,0 +1,16 @@
|
||||
// @module: commonjs
|
||||
// @target: ES5
|
||||
|
||||
// @filename: m1.ts
|
||||
export default function foo() {
|
||||
|
||||
}
|
||||
|
||||
export default function bar() {
|
||||
|
||||
}
|
||||
|
||||
// @filename: m2.ts
|
||||
import Entity from "m1"
|
||||
|
||||
Entity();
|
||||
@@ -1,8 +1,8 @@
|
||||
// In the true branch statement of an ‘if’ statement,
|
||||
// the type of a variable or parameter is narrowed by any type guard in the ‘if’ condition when true,
|
||||
// In the true branch statement of an 'if' statement,
|
||||
// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when true,
|
||||
// provided the true branch statement contains no assignments to the variable or parameter.
|
||||
// In the false branch statement of an ‘if’ statement,
|
||||
// the type of a variable or parameter is narrowed by any type guard in the ‘if’ condition when false,
|
||||
// In the false branch statement of an 'if' statement,
|
||||
// the type of a variable or parameter is narrowed by any type guard in the 'if' condition when false,
|
||||
// provided the false branch statement contains no assignments to the variable or parameter
|
||||
function foo(x: number | string) {
|
||||
if (typeof x === "string") {
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// @module: commonjs
|
||||
// @Filename: foo1.ts
|
||||
class x{}
|
||||
export = x;
|
||||
|
||||
// @Filename: foo2.ts
|
||||
import foo1 = require('./foo1');
|
||||
|
||||
export = {
|
||||
x: foo1
|
||||
}
|
||||
|
||||
// @Filename: foo3.ts
|
||||
import foo2 = require('./foo2')
|
||||
class x extends foo2.x {}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
//@jsx: preserve
|
||||
//@module: amd
|
||||
|
||||
//@filename: react.d.ts
|
||||
declare module JSX {
|
||||
interface Element { }
|
||||
interface IntrinsicElements {
|
||||
}
|
||||
interface ElementAttributesProperty {
|
||||
props;
|
||||
}
|
||||
}
|
||||
|
||||
//@filename: file.tsx
|
||||
export class MyComponent {
|
||||
render() {
|
||||
}
|
||||
|
||||
props: {
|
||||
[s: string]: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
// Should be an error
|
||||
<MyComponent bar='world' />;
|
||||
|
||||
// Should be OK
|
||||
<MyComponent bar={true} />;
|
||||
|
||||
// Should be ok
|
||||
<MyComponent data-bar='hello' />;
|
||||
@@ -1,5 +1,7 @@
|
||||
//@filename: file.tsx
|
||||
//@jsx: preserve
|
||||
//@sourceMap: true
|
||||
|
||||
declare module JSX {
|
||||
interface Element { }
|
||||
interface IntrinsicElements { }
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
//@jsx: react
|
||||
//@module: commonjs
|
||||
|
||||
//@filename: modules.d.ts
|
||||
declare module 'mod' {
|
||||
var y: any;
|
||||
export default y;
|
||||
}
|
||||
|
||||
//@filename: app.tsx
|
||||
import Main from 'mod';
|
||||
declare var Foo, React;
|
||||
// Should see mod_1['default'] in emit here
|
||||
<Foo handler={Main}></Foo>;
|
||||
// Should see mod_1['default'] in emit here
|
||||
<Foo {...Main}></Foo>;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
//@jsx: react
|
||||
//@module: commonjs
|
||||
|
||||
//@filename: file.tsx
|
||||
declare module JSX {
|
||||
interface Element { }
|
||||
interface IntrinsicElements {
|
||||
[s: string]: any;
|
||||
}
|
||||
}
|
||||
|
||||
//@filename: test.d.ts
|
||||
export var React;
|
||||
|
||||
//@filename: react-consumer.tsx
|
||||
import {React} from "./test";
|
||||
// Should emit test_1.React.createElement
|
||||
// and React.__spread
|
||||
var foo;
|
||||
var spread1 = <div x='' {...foo} y='' />;
|
||||
@@ -0,0 +1,22 @@
|
||||
//@jsx: react
|
||||
//@module: commonjs
|
||||
|
||||
//@filename: file.tsx
|
||||
declare module JSX {
|
||||
interface Element { }
|
||||
interface IntrinsicElements {
|
||||
[s: string]: any;
|
||||
}
|
||||
}
|
||||
|
||||
//@filename: react-consumer.tsx
|
||||
namespace M {
|
||||
export var React: any;
|
||||
}
|
||||
|
||||
namespace M {
|
||||
// Should emit M.React.createElement
|
||||
// and M.React.__spread
|
||||
var foo;
|
||||
var spread1 = <div x='' {...foo} y='' />;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
//@filename: file.tsx
|
||||
//@jsx: react
|
||||
declare module JSX {
|
||||
interface Element { }
|
||||
interface IntrinsicElements {
|
||||
[s: string]: any;
|
||||
}
|
||||
}
|
||||
declare var React: any;
|
||||
|
||||
<div>Dot goes here: · ¬AnEntity; </div>;
|
||||
@@ -0,0 +1,17 @@
|
||||
//@filename: file.tsx
|
||||
//@jsx: react
|
||||
declare module JSX {
|
||||
interface Element { }
|
||||
interface IntrinsicElements {
|
||||
[s: string]: any;
|
||||
}
|
||||
}
|
||||
declare var React: any;
|
||||
|
||||
// Emit ' word' in the last string
|
||||
<div>word <code>code</code> word</div>;
|
||||
// Same here
|
||||
<div><code>code</code> word</div>;
|
||||
// And here
|
||||
<div><code /> word</div>;
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
var regex1 = / asdf /;
|
||||
var regex2 = /**// asdf /;
|
||||
var regex3 = /**///**/ asdf / // should be a comment line
|
||||
1;
|
||||
var regex4 = /**// /**/asdf /;
|
||||
var regex5 = /**// asdf/**/ /;
|
||||
@@ -25,12 +25,12 @@ unionOfDifferentNumberOfSignatures(); // error - no call signatures
|
||||
unionOfDifferentNumberOfSignatures(10); // error - no call signatures
|
||||
unionOfDifferentNumberOfSignatures("hello"); // error - no call signatures
|
||||
|
||||
var unionWithDifferentParameterCount: { (a: string): string; } | { (a: string, b: number): number; } ;
|
||||
var unionWithDifferentParameterCount: { (a: string): string; } | { (a: string, b: number): number; } ;
|
||||
unionWithDifferentParameterCount();// no call signature
|
||||
unionWithDifferentParameterCount("hello");// no call signature
|
||||
unionWithDifferentParameterCount("hello", 10);// no call signature
|
||||
|
||||
var unionWithOptionalParameter1: { (a: string, b?: number): string; } | { (a: string, b?: number): number; };
|
||||
var unionWithOptionalParameter1: { (a: string, b?: number): string; } | { (a: string, b?: number): number; };
|
||||
strOrNum = unionWithOptionalParameter1('hello');
|
||||
strOrNum = unionWithOptionalParameter1('hello', 10);
|
||||
strOrNum = unionWithOptionalParameter1('hello', "hello"); // error in parameter type
|
||||
@@ -43,7 +43,7 @@ strOrNum = unionWithOptionalParameter2('hello', "hello"); // error no call signa
|
||||
strOrNum = unionWithOptionalParameter2(); // error no call signature
|
||||
|
||||
var unionWithOptionalParameter3: { (a: string, b?: number): string; } | { (a: string): number; };
|
||||
strOrNum = unionWithOptionalParameter3('hello'); // error no call signature
|
||||
strOrNum = unionWithOptionalParameter3('hello');
|
||||
strOrNum = unionWithOptionalParameter3('hello', 10); // error no call signature
|
||||
strOrNum = unionWithOptionalParameter3('hello', "hello"); // error no call signature
|
||||
strOrNum = unionWithOptionalParameter3(); // error no call signature
|
||||
@@ -63,8 +63,9 @@ strOrNum = unionWithRestParameter2('hello', "hello"); // error no call signature
|
||||
strOrNum = unionWithRestParameter2(); // error no call signature
|
||||
|
||||
var unionWithRestParameter3: { (a: string, ...b: number[]): string; } | { (a: string): number };
|
||||
strOrNum = unionWithRestParameter3('hello'); // error no call signature
|
||||
strOrNum = unionWithRestParameter3('hello');
|
||||
strOrNum = unionWithRestParameter3('hello', 10); // error no call signature
|
||||
strOrNum = unionWithRestParameter3('hello', 10, 11); // error no call signature
|
||||
strOrNum = unionWithRestParameter3('hello', "hello"); // error no call signature
|
||||
strOrNum = unionWithRestParameter3(); // error no call signature
|
||||
strOrNum = unionWithRestParameter3(); // error no call signature
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
interface A {
|
||||
(x: number): number;
|
||||
(x: string, y?: string): boolean;
|
||||
(x: Date): void;
|
||||
<T>(x: T[]): T[];
|
||||
}
|
||||
|
||||
interface B {
|
||||
(x: number): number;
|
||||
(x: string): string;
|
||||
(x: Date): void;
|
||||
<T>(x: T[]): T[];
|
||||
}
|
||||
|
||||
interface C {
|
||||
(x: string, ...y: string[]): number;
|
||||
(x: number, s?: string): number;
|
||||
<T>(x: T[]): T[];
|
||||
}
|
||||
|
||||
var f1: A | B | C;
|
||||
var n1 = f1(42); // number
|
||||
var s1 = f1("abc"); // boolean | string | number
|
||||
var a1 = f1([true, false]); // boolean[]
|
||||
|
||||
var f2: C | B | A;
|
||||
var n2 = f2(42); // number
|
||||
var s2 = f2("abc"); // number | string | boolean
|
||||
var a2 = f2([true, false]); // boolean[]
|
||||
|
||||
var f3: B | A | C;
|
||||
var n3 = f3(42); // number
|
||||
var s3 = f3("abc"); // string | boolean | number
|
||||
var a3 = f3([true, false]); // boolean[]
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
function f1(s: string) { }
|
||||
function f2(s?: string) { }
|
||||
function f3(...s: string[]) { }
|
||||
function f4(s: string, s2?: string) { }
|
||||
function f5(s?: string, n?: number) { }
|
||||
function f6(s?: string, ...n: number[]) { }
|
||||
function f7(s: string, ...sRest: string[]) { }
|
||||
|
||||
var fUnion: typeof f1 | typeof f2 | typeof f3 | typeof f4 | typeof f5 | typeof f6 | typeof f7;
|
||||
|
||||
fUnion(""); // All constituents can be called by passing a single string.
|
||||
@@ -24,7 +24,7 @@ goTo.marker('1');
|
||||
verify.quickInfoIs('var c: {\n name: string;\n age: number;\n}[]');
|
||||
|
||||
goTo.marker('2');
|
||||
verify.quickInfoIs('var c1: ({\n name: string;\n age: number;\n} | {\n name: string;\n age: number;\n dob: Date;\n})[]');
|
||||
verify.quickInfoIs('var c1: {\n name: string;\n age: number;\n}[]');
|
||||
|
||||
goTo.marker('3');
|
||||
verify.quickInfoIs('var c2: ({\n\
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
///<reference path="fourslash.ts" />
|
||||
|
||||
////interface One {
|
||||
//// commonProperty: number;
|
||||
//// commonProperty: string;
|
||||
//// commonFunction(): number;
|
||||
////}
|
||||
////
|
||||
////interface Two {
|
||||
//// commonProperty: string
|
||||
//// commonProperty: number;
|
||||
//// commonFunction(): number;
|
||||
////}
|
||||
////
|
||||
@@ -15,6 +15,6 @@
|
||||
////x.commonProperty./**/
|
||||
|
||||
goTo.marker();
|
||||
verify.memberListContains("toString", "(property) toString: ((radix?: number) => string) | (() => string)");
|
||||
verify.memberListContains("valueOf", "(method) valueOf(): number | string");
|
||||
verify.memberListContains("toString", "(method) toString(): string");
|
||||
verify.memberListContains("valueOf", "(method) valueOf(): string | number");
|
||||
verify.memberListCount(2);
|
||||
@@ -0,0 +1,62 @@
|
||||
///<reference path="fourslash.ts" />
|
||||
|
||||
// @allowNonTsExtensions: true
|
||||
// @Filename: Foo.js
|
||||
/////** @/*1*/ */
|
||||
////var v1;
|
||||
////
|
||||
/////** @p/*2*/ */
|
||||
////var v2;
|
||||
////
|
||||
/////** @param /*3*/ */
|
||||
////var v3;
|
||||
////
|
||||
/////** @param { n/*4*/ } bar */
|
||||
////var v4;
|
||||
////
|
||||
/////** @type { n/*5*/ } */
|
||||
////var v5;
|
||||
////
|
||||
////// @/*6*/
|
||||
////var v6;
|
||||
////
|
||||
////// @pa/*7*/
|
||||
////var v7;
|
||||
////
|
||||
/////** @param { n/*8*/ } */
|
||||
////var v8;
|
||||
////
|
||||
/////** @return { n/*9*/ } */
|
||||
////var v9;
|
||||
|
||||
goTo.marker('1');
|
||||
verify.completionListContains("constructor");
|
||||
verify.completionListContains("param");
|
||||
verify.completionListContains("type");
|
||||
|
||||
goTo.marker('2');
|
||||
verify.completionListContains("constructor");
|
||||
verify.completionListContains("param");
|
||||
verify.completionListContains("type");
|
||||
|
||||
goTo.marker('3');
|
||||
verify.completionListIsEmpty();
|
||||
|
||||
goTo.marker('4');
|
||||
verify.completionListContains('number');
|
||||
|
||||
goTo.marker('5');
|
||||
verify.completionListContains('number');
|
||||
|
||||
goTo.marker('6');
|
||||
verify.completionListIsEmpty();
|
||||
|
||||
goTo.marker('7');
|
||||
verify.completionListIsEmpty();
|
||||
|
||||
goTo.marker('8');
|
||||
verify.completionListContains('number');
|
||||
|
||||
goTo.marker('9');
|
||||
verify.completionListContains('number');
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////function testArguments() {/*1*/}
|
||||
/////*2*/
|
||||
////function testNestedArguments() {
|
||||
//// function nestedfunction(){/*3*/}
|
||||
////}
|
||||
////function f() {
|
||||
//// let g = () => /*4*/
|
||||
////}
|
||||
////let g = () => /*5*/
|
||||
|
||||
goTo.marker('1');
|
||||
verify.completionListContains("arguments");
|
||||
goTo.marker('2');
|
||||
verify.not.completionListContains("arguments");
|
||||
goTo.marker('3');
|
||||
verify.completionListContains("arguments");
|
||||
goTo.marker('4');
|
||||
verify.completionListContains("arguments");
|
||||
goTo.marker('5');
|
||||
verify.not.completionListContains("arguments");
|
||||
@@ -0,0 +1,18 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////var C0 = class D</*0*/
|
||||
////var C1 = class D</*1*/T> {}
|
||||
////var C3 = class D<T, /*2*/
|
||||
////var C4 = class D<T, /*3*/U>{}
|
||||
////var C5 = class D<T extends /*4*/>{}
|
||||
|
||||
goTo.marker("0");
|
||||
verify.completionListIsEmpty();
|
||||
goTo.marker("1");
|
||||
verify.completionListIsEmpty();
|
||||
goTo.marker("2");
|
||||
verify.completionListIsEmpty();
|
||||
goTo.marker("3");
|
||||
verify.completionListIsEmpty();
|
||||
goTo.marker("4");
|
||||
verify.not.completionListIsEmpty();
|
||||
@@ -0,0 +1,17 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////type List1</*0*/
|
||||
////type List2</*1*/T> = T[];
|
||||
////type List4<T> = /*2*/T[];
|
||||
////type List3<T1> = /*3*/;
|
||||
|
||||
goTo.marker("0");
|
||||
verify.completionListIsEmpty();
|
||||
goTo.marker("1");
|
||||
verify.not.completionListIsEmpty();
|
||||
goTo.marker("2");
|
||||
verify.completionListContains("T");
|
||||
goTo.marker("3");
|
||||
verify.not.completionListIsEmpty();
|
||||
verify.not.completionListContains("T");
|
||||
verify.completionListContains("T1");
|
||||
@@ -0,0 +1,19 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////type Map1<K, /*0*/
|
||||
////type Map1<K, /*1*/V> = [];
|
||||
////type Map1<K,V> = /*2*/[];
|
||||
////type Map1<K1, V1> = </*3*/
|
||||
|
||||
goTo.marker("0");
|
||||
verify.completionListIsEmpty();
|
||||
goTo.marker("1");
|
||||
verify.completionListContains("V");
|
||||
goTo.marker("2");
|
||||
verify.completionListContains("K");
|
||||
verify.completionListContains("V");
|
||||
goTo.marker("3");
|
||||
verify.not.completionListContains("K");
|
||||
verify.not.completionListContains("V");
|
||||
verify.completionListContains("K1");
|
||||
verify.completionListContains("V1");
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user