mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
fix merge conflicts with master
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
//@target: ES5
|
||||
|
||||
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
|
||||
let result = [];
|
||||
for (let arg of arguments) {
|
||||
result.push(arg + arg);
|
||||
}
|
||||
return <[any, any, any]>result;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
//@target: ES6
|
||||
|
||||
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
|
||||
let result = [];
|
||||
for (let arg of arguments) {
|
||||
result.push(arg + arg);
|
||||
}
|
||||
return <[any, any, any]>result;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
//@target: ES5
|
||||
|
||||
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
|
||||
let blah = arguments[Symbol.iterator];
|
||||
|
||||
let result = [];
|
||||
for (let arg of blah()) {
|
||||
result.push(arg + arg);
|
||||
}
|
||||
return <[any, any, any]>result;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
//@target: ES6
|
||||
|
||||
function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] {
|
||||
let blah = arguments[Symbol.iterator];
|
||||
|
||||
let result = [];
|
||||
for (let arg of blah()) {
|
||||
result.push(arg + arg);
|
||||
}
|
||||
return <[any, any, any]>result;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
//@target: ES5
|
||||
|
||||
function asReversedTuple(a: number, b: string, c: boolean): [boolean, string, number] {
|
||||
let [x, y, z] = arguments;
|
||||
|
||||
return [z, y, x];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
//@target: ES6
|
||||
|
||||
function asReversedTuple(a: number, b: string, c: boolean): [boolean, string, number] {
|
||||
let [x, y, z] = arguments;
|
||||
|
||||
return [z, y, x];
|
||||
}
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
// @experimentaldecorators: true
|
||||
var v = @decorate class C { static p = 1 };
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace C {
|
||||
export interface type {
|
||||
}
|
||||
}
|
||||
|
||||
var x = class C {
|
||||
prop: C.type;
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
// @newline: \n
|
||||
// @sourcemap: true
|
||||
// DEFAULT INTERFACES
|
||||
interface IFoo {
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
function foo<T>() {
|
||||
var z = foo<typeof y>();
|
||||
var y: {
|
||||
y2: typeof z
|
||||
};
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
function bar<T>() {
|
||||
var z = bar<typeof y>();
|
||||
var y: {
|
||||
y2: typeof z;
|
||||
}
|
||||
return y;
|
||||
}
|
||||
|
||||
var a = foo<number>();
|
||||
var b = bar<number>();
|
||||
a = b;
|
||||
@@ -0,0 +1,20 @@
|
||||
function foo<T>() {
|
||||
var x: {
|
||||
a: T;
|
||||
b: typeof x;
|
||||
};
|
||||
return x;
|
||||
}
|
||||
|
||||
function bar<T>() {
|
||||
var x: {
|
||||
a: T;
|
||||
b: typeof x;
|
||||
};
|
||||
return x;
|
||||
}
|
||||
|
||||
var a = foo<string>();
|
||||
var b = bar<string>();
|
||||
// Relating types of a and b produces instantiations of the cyclic anonymous types in foo and bar
|
||||
a = b;
|
||||
@@ -0,0 +1,6 @@
|
||||
class C {
|
||||
}
|
||||
|
||||
var declare: any;
|
||||
|
||||
declare instanceof C;
|
||||
@@ -0,0 +1,3 @@
|
||||
declare type Foo = string;
|
||||
type Bar = number;
|
||||
declare type Baz = Bar;
|
||||
@@ -0,0 +1,10 @@
|
||||
// @target: es5
|
||||
|
||||
function f0(a, [a, [b]], {b}) { }
|
||||
function f1([a, a]) { }
|
||||
function f2({b}, {b}) { }
|
||||
function f3([c,[c],[[c]]]) { }
|
||||
function f4({d, d:{d}}) { }
|
||||
function f5({e, e: {e}}, {e}, [d,e, [[e]]], ...e) { }
|
||||
function f6([f, ...f]) { }
|
||||
function f7(a, func = (a) => { return 1 }) { } // not error
|
||||
@@ -0,0 +1,11 @@
|
||||
// @target: es5
|
||||
|
||||
"use strict"
|
||||
function f0(a, [a, [b]], {b}) { }
|
||||
function f1([a, a]) { }
|
||||
function f2({b}, {b}) { }
|
||||
function f3([c, [c], [[c]]]) { }
|
||||
function f4({d, d: {d}}) { }
|
||||
function f5({e, e: {e}}, {e}, [d, e, [[e]]], ...e) { }
|
||||
function f6([f, ...f]) { }
|
||||
function f7(a, func = (a) => { return 1 }){ } // not error
|
||||
@@ -0,0 +1,7 @@
|
||||
// Regression test for #3018
|
||||
|
||||
declare var io: any;
|
||||
|
||||
declare module 'module' {
|
||||
export default io;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
interface arguments {
|
||||
}
|
||||
|
||||
function f() {
|
||||
<arguments>arguments;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
interface f {
|
||||
}
|
||||
|
||||
function f() {
|
||||
<f>f;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
interface arguments {
|
||||
}
|
||||
|
||||
var x = function f() {
|
||||
<arguments>arguments;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
interface f {
|
||||
}
|
||||
|
||||
var x = function f() {
|
||||
<f>f;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
interface Foo {
|
||||
}
|
||||
|
||||
var x = function Foo() {
|
||||
var x: Foo;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
interface Int<T, U> {
|
||||
method(x: T): U;
|
||||
}
|
||||
declare function foo<T, U>(x: T, y: Int<T, U>, z: Int<U, T>): T;
|
||||
foo("", { method(p1) { return p1.length } }, { method(p2) { return undefined } });
|
||||
@@ -0,0 +1,5 @@
|
||||
interface Int<T, U> {
|
||||
[s: string]: (x: T) => U;
|
||||
}
|
||||
declare function foo<T, U>(x: T, y: Int<T, U>, z: Int<U, T>): T;
|
||||
foo("", { method(p1) { return p1.length } }, { method(p2) { return undefined } });
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// @separateCompilation: true
|
||||
// @isolatedModules: true
|
||||
// @target: es6
|
||||
|
||||
// @filename: file1.ts
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// @separateCompilation: true
|
||||
// @isolatedModules: true
|
||||
// @declaration: true
|
||||
// @target: es6
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// @separateCompilation: true
|
||||
// @isolatedModules: true
|
||||
// @target: es6
|
||||
// @filename: file1.ts
|
||||
export var x;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// @separateCompilation: true
|
||||
// @isolatedModules: true
|
||||
// @target: es5
|
||||
// @module: commonjs
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// @separateCompilation: true
|
||||
// @isolatedModules: true
|
||||
// @noEmitOnError:true
|
||||
// @target: es6
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// @separateCompilation: true
|
||||
// @isolatedModules: true
|
||||
// @target: es6
|
||||
|
||||
// @filename: file1.ts
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// @separateCompilation: true
|
||||
// @isolatedModules: true
|
||||
// @target: es6
|
||||
|
||||
// @filename: file1.ts
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// @separateCompilation: true
|
||||
// @isolatedModules: true
|
||||
// @out:all.js
|
||||
// @target: es6
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
// @target: es5
|
||||
// @module: amd
|
||||
// @separateCompilation: true
|
||||
// @isolatedModules: true
|
||||
|
||||
declare function run(a: number): void;
|
||||
run(1);
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
// @target: es5
|
||||
// @module: commonjs
|
||||
// @separateCompilation: true
|
||||
// @isolatedModules: true
|
||||
|
||||
declare function run(a: number): void;
|
||||
run(1);
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// @target: es6
|
||||
// @separateCompilation: true
|
||||
// @isolatedModules: true
|
||||
|
||||
declare function run(a: number): void;
|
||||
run(1);
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
// @target: es5
|
||||
// @module: system
|
||||
// @separateCompilation: true
|
||||
// @isolatedModules: true
|
||||
|
||||
declare function run(a: number): void;
|
||||
run(1);
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
// @target: es5
|
||||
// @module: umd
|
||||
// @separateCompilation: true
|
||||
// @isolatedModules: true
|
||||
|
||||
declare function run(a: number): void;
|
||||
run(1);
|
||||
@@ -0,0 +1,6 @@
|
||||
// @isolatedModules: true
|
||||
// @sourceMap:true
|
||||
// @target: es6
|
||||
|
||||
// @filename: file1.ts
|
||||
export var x;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// @separateCompilation: true
|
||||
// @isolatedModules: true
|
||||
// @module: commonjs
|
||||
// @filename: file1.ts
|
||||
export var x;
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
// @separateCompilation: true
|
||||
// @isolatedModules: true
|
||||
// @filename: file1.ts
|
||||
export var x;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// @separateCompilation: true
|
||||
// @isolatedModules: true
|
||||
// @target: es6
|
||||
|
||||
// @filename: file1.d.ts
|
||||
@@ -0,0 +1,24 @@
|
||||
class Match {
|
||||
public range(): any {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
class FileMatch {
|
||||
public resource(): any {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
type FileMatchOrMatch = FileMatch | Match;
|
||||
|
||||
|
||||
let elementA: FileMatchOrMatch, elementB: FileMatchOrMatch;
|
||||
|
||||
if (elementA instanceof FileMatch && elementB instanceof FileMatch) {
|
||||
let a = elementA.resource().path;
|
||||
let b = elementB.resource().path;
|
||||
} else if (elementA instanceof Match && elementB instanceof Match) {
|
||||
let a = elementA.range();
|
||||
let b = elementB.range();
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// @newline: CRLF
|
||||
var x=1;
|
||||
x=2;
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
// @newline: LF
|
||||
var x=1;
|
||||
x=2;
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
// @noemithelpers: true
|
||||
|
||||
class A { }
|
||||
class B extends A { }
|
||||
@@ -0,0 +1,12 @@
|
||||
// @noemithelpers: true
|
||||
// @experimentaldecorators: true
|
||||
// @emitdecoratormetadata: true
|
||||
// @target: es5
|
||||
|
||||
function decorator() { }
|
||||
|
||||
@decorator
|
||||
class A {
|
||||
constructor(a: number, @decorator b: string) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
//@target: ES6
|
||||
interface T1 {
|
||||
__t1: string;
|
||||
}
|
||||
|
||||
interface T2 {
|
||||
__t2: string;
|
||||
}
|
||||
|
||||
interface T3 {
|
||||
__t3: string;
|
||||
}
|
||||
|
||||
function f1(): Promise<T1> {
|
||||
return Promise.resolve({ __t1: "foo_t1" });
|
||||
}
|
||||
|
||||
function f2(x: T1): T2 {
|
||||
return { __t2: x.__t1 + ":foo_21" };
|
||||
}
|
||||
|
||||
var x3 = f1()
|
||||
.then(f2, (e: Error) => {
|
||||
throw e;
|
||||
})
|
||||
.then((x: T2) => {
|
||||
return { __t3: x.__t2 + "bar" };
|
||||
});
|
||||
@@ -1,6 +0,0 @@
|
||||
// @separateCompilation: true
|
||||
// @sourceMap:sourcemap.map
|
||||
// @target: es6
|
||||
|
||||
// @filename: file1.ts
|
||||
export var x;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
//@sourceMap: true
|
||||
module Q {
|
||||
function P() {
|
||||
// Test this
|
||||
var a = 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
//@sourceMap: true
|
||||
function P() {
|
||||
// Test this
|
||||
var a = 1;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
// @sourcemap: true
|
||||
// @target: es5
|
||||
// @experimentaldecorators: true
|
||||
declare function ClassDecorator1(target: Function): void;
|
||||
declare function ClassDecorator2(x: number): (target: Function) => void;
|
||||
declare function PropertyDecorator1(target: Object, key: string | symbol, descriptor?: PropertyDescriptor): void;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// @module: system
|
||||
// @separateCompilation: true
|
||||
// @isolatedModules: true
|
||||
|
||||
import n, {x} from 'file1'
|
||||
import n2 = require('file2');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// @target: es5
|
||||
// @module: system
|
||||
// @separateCompilation: true
|
||||
// @isolatedModules: true
|
||||
|
||||
import n, {x} from 'file1'
|
||||
import n2 = require('file2');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// @module: system
|
||||
// @separateCompilation: true
|
||||
// @isolatedModules: true
|
||||
|
||||
// set of tests cases that checks generation of local storage for exported names
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// @module: system
|
||||
// @isolatedModules: true
|
||||
|
||||
///<amd-module name='NamedModule'/>
|
||||
import n from 'file1'
|
||||
@@ -1,5 +1,5 @@
|
||||
// @module: system
|
||||
// @separateCompilation: true
|
||||
// @isolatedModules: true
|
||||
|
||||
import * as ns from 'file1';
|
||||
import {a, b as c} from 'file2';
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// @module: system
|
||||
// @isolatedModules: true
|
||||
|
||||
// @filename: file1.ts
|
||||
declare class Promise { }
|
||||
declare function Foo(): void;
|
||||
declare class C {}
|
||||
declare enum E {X = 1};
|
||||
|
||||
export var promise = Promise;
|
||||
export var foo = Foo;
|
||||
export var c = C;
|
||||
export var e = E;
|
||||
|
||||
// @filename: file2.ts
|
||||
export declare function foo();
|
||||
|
||||
// @filename: file3.ts
|
||||
export declare class C {}
|
||||
|
||||
// @filename: file4.ts
|
||||
export declare var v: number;
|
||||
|
||||
// @filename: file5.ts
|
||||
export declare enum E {X = 1}
|
||||
|
||||
// @filename: file6.ts
|
||||
export declare module M { var v: number; }
|
||||
@@ -0,0 +1,13 @@
|
||||
// @module: system
|
||||
|
||||
declare function use(a: any);
|
||||
const enum TopLevelConstEnum { X }
|
||||
|
||||
export function foo() {
|
||||
use(TopLevelConstEnum.X);
|
||||
use(M.NonTopLevelConstEnum.X);
|
||||
}
|
||||
|
||||
module M {
|
||||
export const enum NonTopLevelConstEnum { X }
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// @module: system
|
||||
// @isolatedModules: true
|
||||
|
||||
declare function use(a: any);
|
||||
const enum TopLevelConstEnum { X }
|
||||
|
||||
export function foo() {
|
||||
use(TopLevelConstEnum.X);
|
||||
use(M.NonTopLevelConstEnum.X);
|
||||
}
|
||||
|
||||
module M {
|
||||
export const enum NonTopLevelConstEnum { X }
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// @module: system
|
||||
// @isolatedModules: true
|
||||
|
||||
export function F() {}
|
||||
export module F { var x; }
|
||||
|
||||
export class C {}
|
||||
export module C { var x; }
|
||||
|
||||
export enum E {}
|
||||
export module E { var x; }
|
||||
@@ -0,0 +1,14 @@
|
||||
// @module: system
|
||||
|
||||
// @filename: file1.ts
|
||||
export default function() {}
|
||||
|
||||
// @filename: file2.ts
|
||||
export default function foo() {}
|
||||
|
||||
// @filename: file3.ts
|
||||
export default class {}
|
||||
|
||||
// @filename: file4.ts
|
||||
export default class C {}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// @module: system
|
||||
// @isolatedModules: true
|
||||
|
||||
export class TopLevelClass {}
|
||||
export module TopLevelModule {var v;}
|
||||
export function TopLevelFunction(): void {}
|
||||
export enum TopLevelEnum {E}
|
||||
|
||||
export module TopLevelModule2 {
|
||||
export class NonTopLevelClass {}
|
||||
export module NonTopLevelModule {var v;}
|
||||
export function NonTopLevelFunction(): void {}
|
||||
export enum NonTopLevelEnum {E}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
//@noImplicitAny: true
|
||||
var foo = { bar() { return undefined } };
|
||||
@@ -0,0 +1,2 @@
|
||||
//@noImplicitAny: true
|
||||
var foo = () => undefined;
|
||||
@@ -0,0 +1,18 @@
|
||||
class Module {
|
||||
public members: Class[];
|
||||
}
|
||||
|
||||
class Namespace {
|
||||
public members: (Class | Property)[];
|
||||
}
|
||||
|
||||
class Class {
|
||||
public parent: Namespace;
|
||||
}
|
||||
|
||||
class Property {
|
||||
public parent: Module | Class;
|
||||
}
|
||||
|
||||
var t: Class | Property;
|
||||
t.parent;
|
||||
@@ -0,0 +1,20 @@
|
||||
class Module {
|
||||
public members: Class[];
|
||||
}
|
||||
|
||||
class Namespace {
|
||||
public members: (Class | Property)[];
|
||||
}
|
||||
|
||||
class Class {
|
||||
public parent: Namespace;
|
||||
}
|
||||
|
||||
class Property {
|
||||
public parent: Module | Class;
|
||||
}
|
||||
|
||||
var c: Class;
|
||||
var p: Property;
|
||||
c = p;
|
||||
p = c;
|
||||
@@ -0,0 +1,5 @@
|
||||
var a27: { prop: number } | { prop: T27 };
|
||||
type T27 = typeof a27;
|
||||
|
||||
var b: T27;
|
||||
var s: string = b;
|
||||
Reference in New Issue
Block a user