mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-12 20:25:48 -06:00
Merge pull request #657 from Microsoft/conformanceTests-624
Conformance Tests for Spec Change in PR#624
This commit is contained in:
commit
3e1b6b896c
@ -1,70 +0,0 @@
|
||||
tests/cases/compiler/defaultArgsForwardReferencing.ts(6,20): error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||||
tests/cases/compiler/defaultArgsForwardReferencing.ts(11,21): error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||||
tests/cases/compiler/defaultArgsForwardReferencing.ts(11,28): error TS2373: Initializer of parameter 'b' cannot reference identifier 'c' declared after it.
|
||||
tests/cases/compiler/defaultArgsForwardReferencing.ts(17,21): error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||||
tests/cases/compiler/defaultArgsForwardReferencing.ts(23,25): error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||||
tests/cases/compiler/defaultArgsForwardReferencing.ts(32,21): error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||||
tests/cases/compiler/defaultArgsForwardReferencing.ts(33,16): error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||||
tests/cases/compiler/defaultArgsForwardReferencing.ts(37,14): error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||||
tests/cases/compiler/defaultArgsForwardReferencing.ts(37,21): error TS2373: Initializer of parameter 'b' cannot reference identifier 'c' declared after it.
|
||||
tests/cases/compiler/defaultArgsForwardReferencing.ts(37,28): error TS2373: Initializer of parameter 'c' cannot reference identifier 'd' declared after it.
|
||||
|
||||
|
||||
==== tests/cases/compiler/defaultArgsForwardReferencing.ts (10 errors) ====
|
||||
function left(a, b = a, c = b) {
|
||||
a;
|
||||
b;
|
||||
}
|
||||
|
||||
function right(a = b, b = a) {
|
||||
~
|
||||
!!! error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||||
a;
|
||||
b;
|
||||
}
|
||||
|
||||
function right2(a = b, b = c, c = a) {
|
||||
~
|
||||
!!! error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||||
~
|
||||
!!! error TS2373: Initializer of parameter 'b' cannot reference identifier 'c' declared after it.
|
||||
a;
|
||||
b;
|
||||
c;
|
||||
}
|
||||
|
||||
function inside(a = b) {
|
||||
~
|
||||
!!! error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||||
var b;
|
||||
}
|
||||
|
||||
function outside() {
|
||||
var b;
|
||||
function inside(a = b) { // Still an error because b is declared inside the function
|
||||
~
|
||||
!!! error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||||
var b;
|
||||
}
|
||||
}
|
||||
|
||||
function defaultArgFunction(a = function () { return b; }, b = 1) { }
|
||||
function defaultArgArrow(a = () => () => b, b = 3) { }
|
||||
|
||||
class C {
|
||||
constructor(a = b, b = 1) { }
|
||||
~
|
||||
!!! error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||||
method(a = b, b = 1) { }
|
||||
~
|
||||
!!! error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||||
}
|
||||
|
||||
// Function expressions
|
||||
var x = (a = b, b = c, c = d) => { var d; };
|
||||
~
|
||||
!!! error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||||
~
|
||||
!!! error TS2373: Initializer of parameter 'b' cannot reference identifier 'c' declared after it.
|
||||
~
|
||||
!!! error TS2373: Initializer of parameter 'c' cannot reference identifier 'd' declared after it.
|
||||
@ -0,0 +1,102 @@
|
||||
tests/cases/conformance/types/typeRelationships/typeInference/genericCallToOverloadedMethodWithOverloadedArguments.ts(24,38): error TS2345: Argument of type '{ (n: number): Promise<number>; (s: string): Promise<string>; }' is not assignable to parameter of type '(x: number) => Promise<string>'.
|
||||
tests/cases/conformance/types/typeRelationships/typeInference/genericCallToOverloadedMethodWithOverloadedArguments.ts(53,38): error TS2345: Argument of type '{ (n: number): Promise<number>; (s: string): Promise<string>; }' is not assignable to parameter of type '(x: number) => Promise<string>'.
|
||||
tests/cases/conformance/types/typeRelationships/typeInference/genericCallToOverloadedMethodWithOverloadedArguments.ts(69,38): error TS2345: Argument of type '{ (n: number): Promise<number>; (s: string): Promise<string>; }' is not assignable to parameter of type '(x: number) => Promise<string>'.
|
||||
tests/cases/conformance/types/typeRelationships/typeInference/genericCallToOverloadedMethodWithOverloadedArguments.ts(85,38): error TS2345: Argument of type '{ (n: number): Promise<number>; (s: string): Promise<string>; (b: boolean): Promise<boolean>; }' is not assignable to parameter of type '(x: number) => Promise<boolean>'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallToOverloadedMethodWithOverloadedArguments.ts (4 errors) ====
|
||||
|
||||
module m1 {
|
||||
interface Promise<T> {
|
||||
then<U>(cb: (x: T) => Promise<U>): Promise<U>;
|
||||
}
|
||||
|
||||
declare function testFunction(n: number): Promise<number>;
|
||||
|
||||
var numPromise: Promise<number>;
|
||||
var newPromise = numPromise.then(testFunction);
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
|
||||
module m2 {
|
||||
interface Promise<T> {
|
||||
then<U>(cb: (x: T) => Promise<U>): Promise<U>;
|
||||
}
|
||||
|
||||
declare function testFunction(n: number): Promise<number>;
|
||||
declare function testFunction(s: string): Promise<string>;
|
||||
|
||||
var numPromise: Promise<number>;
|
||||
var newPromise = numPromise.then(testFunction);
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ (n: number): Promise<number>; (s: string): Promise<string>; }' is not assignable to parameter of type '(x: number) => Promise<string>'.
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
|
||||
module m3 {
|
||||
interface Promise<T> {
|
||||
then<U>(cb: (x: T) => Promise<U>): Promise<U>;
|
||||
then<U>(cb: (x: T) => Promise<U>, error?: (error: any) => Promise<U>): Promise<U>;
|
||||
}
|
||||
|
||||
declare function testFunction(n: number): Promise<number>;
|
||||
|
||||
var numPromise: Promise<number>;
|
||||
var newPromise = numPromise.then(testFunction);
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
|
||||
module m4 {
|
||||
interface Promise<T> {
|
||||
then<U>(cb: (x: T) => Promise<U>): Promise<U>;
|
||||
then<U>(cb: (x: T) => Promise<U>, error?: (error: any) => Promise<U>): Promise<U>;
|
||||
}
|
||||
|
||||
declare function testFunction(n: number): Promise<number>;
|
||||
declare function testFunction(s: string): Promise<string>;
|
||||
|
||||
var numPromise: Promise<number>;
|
||||
var newPromise = numPromise.then(testFunction);
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ (n: number): Promise<number>; (s: string): Promise<string>; }' is not assignable to parameter of type '(x: number) => Promise<string>'.
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
|
||||
module m5 {
|
||||
interface Promise<T> {
|
||||
then<U>(cb: (x: T) => Promise<U>): Promise<U>;
|
||||
then<U>(cb: (x: T) => Promise<U>, error?: (error: any) => Promise<U>): Promise<U>;
|
||||
then<U>(cb: (x: T) => Promise<U>, error?: (error: any) => U, progress?: (preservation: any) => void): Promise<U>;
|
||||
}
|
||||
|
||||
declare function testFunction(n: number): Promise<number>;
|
||||
declare function testFunction(s: string): Promise<string>;
|
||||
|
||||
var numPromise: Promise<number>;
|
||||
var newPromise = numPromise.then(testFunction);
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ (n: number): Promise<number>; (s: string): Promise<string>; }' is not assignable to parameter of type '(x: number) => Promise<string>'.
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
|
||||
module m6 {
|
||||
interface Promise<T> {
|
||||
then<U>(cb: (x: T) => Promise<U>): Promise<U>;
|
||||
then<U>(cb: (x: T) => Promise<U>, error?: (error: any) => Promise<U>): Promise<U>;
|
||||
}
|
||||
|
||||
declare function testFunction(n: number): Promise<number>;
|
||||
declare function testFunction(s: string): Promise<string>;
|
||||
declare function testFunction(b: boolean): Promise<boolean>;
|
||||
|
||||
var numPromise: Promise<number>;
|
||||
var newPromise = numPromise.then(testFunction);
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ (n: number): Promise<number>; (s: string): Promise<string>; (b: boolean): Promise<boolean>; }' is not assignable to parameter of type '(x: number) => Promise<boolean>'.
|
||||
}
|
||||
|
||||
@ -0,0 +1,125 @@
|
||||
//// [genericCallToOverloadedMethodWithOverloadedArguments.ts]
|
||||
|
||||
module m1 {
|
||||
interface Promise<T> {
|
||||
then<U>(cb: (x: T) => Promise<U>): Promise<U>;
|
||||
}
|
||||
|
||||
declare function testFunction(n: number): Promise<number>;
|
||||
|
||||
var numPromise: Promise<number>;
|
||||
var newPromise = numPromise.then(testFunction);
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
|
||||
module m2 {
|
||||
interface Promise<T> {
|
||||
then<U>(cb: (x: T) => Promise<U>): Promise<U>;
|
||||
}
|
||||
|
||||
declare function testFunction(n: number): Promise<number>;
|
||||
declare function testFunction(s: string): Promise<string>;
|
||||
|
||||
var numPromise: Promise<number>;
|
||||
var newPromise = numPromise.then(testFunction);
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
|
||||
module m3 {
|
||||
interface Promise<T> {
|
||||
then<U>(cb: (x: T) => Promise<U>): Promise<U>;
|
||||
then<U>(cb: (x: T) => Promise<U>, error?: (error: any) => Promise<U>): Promise<U>;
|
||||
}
|
||||
|
||||
declare function testFunction(n: number): Promise<number>;
|
||||
|
||||
var numPromise: Promise<number>;
|
||||
var newPromise = numPromise.then(testFunction);
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
|
||||
module m4 {
|
||||
interface Promise<T> {
|
||||
then<U>(cb: (x: T) => Promise<U>): Promise<U>;
|
||||
then<U>(cb: (x: T) => Promise<U>, error?: (error: any) => Promise<U>): Promise<U>;
|
||||
}
|
||||
|
||||
declare function testFunction(n: number): Promise<number>;
|
||||
declare function testFunction(s: string): Promise<string>;
|
||||
|
||||
var numPromise: Promise<number>;
|
||||
var newPromise = numPromise.then(testFunction);
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
|
||||
module m5 {
|
||||
interface Promise<T> {
|
||||
then<U>(cb: (x: T) => Promise<U>): Promise<U>;
|
||||
then<U>(cb: (x: T) => Promise<U>, error?: (error: any) => Promise<U>): Promise<U>;
|
||||
then<U>(cb: (x: T) => Promise<U>, error?: (error: any) => U, progress?: (preservation: any) => void): Promise<U>;
|
||||
}
|
||||
|
||||
declare function testFunction(n: number): Promise<number>;
|
||||
declare function testFunction(s: string): Promise<string>;
|
||||
|
||||
var numPromise: Promise<number>;
|
||||
var newPromise = numPromise.then(testFunction);
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
|
||||
module m6 {
|
||||
interface Promise<T> {
|
||||
then<U>(cb: (x: T) => Promise<U>): Promise<U>;
|
||||
then<U>(cb: (x: T) => Promise<U>, error?: (error: any) => Promise<U>): Promise<U>;
|
||||
}
|
||||
|
||||
declare function testFunction(n: number): Promise<number>;
|
||||
declare function testFunction(s: string): Promise<string>;
|
||||
declare function testFunction(b: boolean): Promise<boolean>;
|
||||
|
||||
var numPromise: Promise<number>;
|
||||
var newPromise = numPromise.then(testFunction);
|
||||
}
|
||||
|
||||
|
||||
//// [genericCallToOverloadedMethodWithOverloadedArguments.js]
|
||||
var m1;
|
||||
(function (m1) {
|
||||
var numPromise;
|
||||
var newPromise = numPromise.then(testFunction);
|
||||
})(m1 || (m1 = {}));
|
||||
//////////////////////////////////////
|
||||
var m2;
|
||||
(function (m2) {
|
||||
var numPromise;
|
||||
var newPromise = numPromise.then(testFunction);
|
||||
})(m2 || (m2 = {}));
|
||||
//////////////////////////////////////
|
||||
var m3;
|
||||
(function (m3) {
|
||||
var numPromise;
|
||||
var newPromise = numPromise.then(testFunction);
|
||||
})(m3 || (m3 = {}));
|
||||
//////////////////////////////////////
|
||||
var m4;
|
||||
(function (m4) {
|
||||
var numPromise;
|
||||
var newPromise = numPromise.then(testFunction);
|
||||
})(m4 || (m4 = {}));
|
||||
//////////////////////////////////////
|
||||
var m5;
|
||||
(function (m5) {
|
||||
var numPromise;
|
||||
var newPromise = numPromise.then(testFunction);
|
||||
})(m5 || (m5 = {}));
|
||||
//////////////////////////////////////
|
||||
var m6;
|
||||
(function (m6) {
|
||||
var numPromise;
|
||||
var newPromise = numPromise.then(testFunction);
|
||||
})(m6 || (m6 = {}));
|
||||
@ -22,6 +22,10 @@ module A {
|
||||
return 'hello ' + s;
|
||||
}
|
||||
var ol = { s: 'hello', id: 2, isvalid: true };
|
||||
|
||||
declare class DC {
|
||||
static x: number;
|
||||
}
|
||||
}
|
||||
|
||||
module Y {
|
||||
@ -47,6 +51,10 @@ module Y {
|
||||
return 'hello ' + s;
|
||||
}
|
||||
export var ol = { s: 'hello', id: 2, isvalid: true };
|
||||
|
||||
export declare class DC {
|
||||
static x: number;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -71,6 +71,13 @@ module A {
|
||||
>s : string
|
||||
>id : number
|
||||
>isvalid : boolean
|
||||
|
||||
declare class DC {
|
||||
>DC : DC
|
||||
|
||||
static x: number;
|
||||
>x : number
|
||||
}
|
||||
}
|
||||
|
||||
module Y {
|
||||
@ -145,5 +152,12 @@ module Y {
|
||||
>s : string
|
||||
>id : number
|
||||
>isvalid : boolean
|
||||
|
||||
export declare class DC {
|
||||
>DC : DC
|
||||
|
||||
static x: number;
|
||||
>x : number
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,74 @@
|
||||
tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(6,20): error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||||
tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(11,21): error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||||
tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(11,28): error TS2373: Initializer of parameter 'b' cannot reference identifier 'c' declared after it.
|
||||
tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(17,21): error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||||
tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(23,25): error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||||
tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(32,21): error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||||
tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(33,16): error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||||
tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(37,14): error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||||
tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(37,21): error TS2373: Initializer of parameter 'b' cannot reference identifier 'c' declared after it.
|
||||
tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts(37,28): error TS2373: Initializer of parameter 'c' cannot reference identifier 'd' declared after it.
|
||||
|
||||
|
||||
==== tests/cases/conformance/functions/parameterInitializersForwardReferencing.ts (10 errors) ====
|
||||
function left(a, b = a, c = b) {
|
||||
a;
|
||||
b;
|
||||
}
|
||||
|
||||
function right(a = b, b = a) {
|
||||
~
|
||||
!!! error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||||
a;
|
||||
b;
|
||||
}
|
||||
|
||||
function right2(a = b, b = c, c = a) {
|
||||
~
|
||||
!!! error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||||
~
|
||||
!!! error TS2373: Initializer of parameter 'b' cannot reference identifier 'c' declared after it.
|
||||
a;
|
||||
b;
|
||||
c;
|
||||
}
|
||||
|
||||
function inside(a = b) {
|
||||
~
|
||||
!!! error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||||
var b;
|
||||
}
|
||||
|
||||
function outside() {
|
||||
var b;
|
||||
function inside(a = b) { // Still an error because b is declared inside the function
|
||||
~
|
||||
!!! error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||||
var b;
|
||||
}
|
||||
}
|
||||
|
||||
function defaultArgFunction(a = function () { return b; }, b = 1) { }
|
||||
function defaultArgArrow(a = () => () => b, b = 3) { }
|
||||
|
||||
class C {
|
||||
constructor(a = b, b = 1) { }
|
||||
~
|
||||
!!! error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||||
method(a = b, b = 1) { }
|
||||
~
|
||||
!!! error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||||
}
|
||||
|
||||
// Function expressions
|
||||
var x = (a = b, b = c, c = d) => { var d; };
|
||||
~
|
||||
!!! error TS2373: Initializer of parameter 'a' cannot reference identifier 'b' declared after it.
|
||||
~
|
||||
!!! error TS2373: Initializer of parameter 'b' cannot reference identifier 'c' declared after it.
|
||||
~
|
||||
!!! error TS2373: Initializer of parameter 'c' cannot reference identifier 'd' declared after it.
|
||||
|
||||
// Should not produce errors - can reference later parameters if they occur within a function expression initializer.
|
||||
function f(a, b = function () { return c; }, c = b()) {
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
//// [defaultArgsForwardReferencing.ts]
|
||||
//// [parameterInitializersForwardReferencing.ts]
|
||||
function left(a, b = a, c = b) {
|
||||
a;
|
||||
b;
|
||||
@ -35,9 +35,13 @@ class C {
|
||||
}
|
||||
|
||||
// Function expressions
|
||||
var x = (a = b, b = c, c = d) => { var d; };
|
||||
var x = (a = b, b = c, c = d) => { var d; };
|
||||
|
||||
// Should not produce errors - can reference later parameters if they occur within a function expression initializer.
|
||||
function f(a, b = function () { return c; }, c = b()) {
|
||||
}
|
||||
|
||||
//// [defaultArgsForwardReferencing.js]
|
||||
//// [parameterInitializersForwardReferencing.js]
|
||||
function left(a, b, c) {
|
||||
if (b === void 0) { b = a; }
|
||||
if (c === void 0) { c = b; }
|
||||
@ -97,3 +101,10 @@ var x = function (a, b, c) {
|
||||
if (c === void 0) { c = d; }
|
||||
var d;
|
||||
};
|
||||
// Should not produce errors - can reference later parameters if they occur within a function expression initializer.
|
||||
function f(a, b, c) {
|
||||
if (b === void 0) { b = function () {
|
||||
return c;
|
||||
}; }
|
||||
if (c === void 0) { c = b(); }
|
||||
}
|
||||
@ -34,4 +34,8 @@ class C {
|
||||
}
|
||||
|
||||
// Function expressions
|
||||
var x = (a = b, b = c, c = d) => { var d; };
|
||||
var x = (a = b, b = c, c = d) => { var d; };
|
||||
|
||||
// Should not produce errors - can reference later parameters if they occur within a function expression initializer.
|
||||
function f(a, b = function () { return c; }, c = b()) {
|
||||
}
|
||||
@ -21,6 +21,10 @@ module A {
|
||||
return 'hello ' + s;
|
||||
}
|
||||
var ol = { s: 'hello', id: 2, isvalid: true };
|
||||
|
||||
declare class DC {
|
||||
static x: number;
|
||||
}
|
||||
}
|
||||
|
||||
module Y {
|
||||
@ -46,4 +50,8 @@ module Y {
|
||||
return 'hello ' + s;
|
||||
}
|
||||
export var ol = { s: 'hello', id: 2, isvalid: true };
|
||||
|
||||
export declare class DC {
|
||||
static x: number;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,86 @@
|
||||
|
||||
module m1 {
|
||||
interface Promise<T> {
|
||||
then<U>(cb: (x: T) => Promise<U>): Promise<U>;
|
||||
}
|
||||
|
||||
declare function testFunction(n: number): Promise<number>;
|
||||
|
||||
var numPromise: Promise<number>;
|
||||
var newPromise = numPromise.then(testFunction);
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
|
||||
module m2 {
|
||||
interface Promise<T> {
|
||||
then<U>(cb: (x: T) => Promise<U>): Promise<U>;
|
||||
}
|
||||
|
||||
declare function testFunction(n: number): Promise<number>;
|
||||
declare function testFunction(s: string): Promise<string>;
|
||||
|
||||
var numPromise: Promise<number>;
|
||||
var newPromise = numPromise.then(testFunction);
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
|
||||
module m3 {
|
||||
interface Promise<T> {
|
||||
then<U>(cb: (x: T) => Promise<U>): Promise<U>;
|
||||
then<U>(cb: (x: T) => Promise<U>, error?: (error: any) => Promise<U>): Promise<U>;
|
||||
}
|
||||
|
||||
declare function testFunction(n: number): Promise<number>;
|
||||
|
||||
var numPromise: Promise<number>;
|
||||
var newPromise = numPromise.then(testFunction);
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
|
||||
module m4 {
|
||||
interface Promise<T> {
|
||||
then<U>(cb: (x: T) => Promise<U>): Promise<U>;
|
||||
then<U>(cb: (x: T) => Promise<U>, error?: (error: any) => Promise<U>): Promise<U>;
|
||||
}
|
||||
|
||||
declare function testFunction(n: number): Promise<number>;
|
||||
declare function testFunction(s: string): Promise<string>;
|
||||
|
||||
var numPromise: Promise<number>;
|
||||
var newPromise = numPromise.then(testFunction);
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
|
||||
module m5 {
|
||||
interface Promise<T> {
|
||||
then<U>(cb: (x: T) => Promise<U>): Promise<U>;
|
||||
then<U>(cb: (x: T) => Promise<U>, error?: (error: any) => Promise<U>): Promise<U>;
|
||||
then<U>(cb: (x: T) => Promise<U>, error?: (error: any) => U, progress?: (preservation: any) => void): Promise<U>;
|
||||
}
|
||||
|
||||
declare function testFunction(n: number): Promise<number>;
|
||||
declare function testFunction(s: string): Promise<string>;
|
||||
|
||||
var numPromise: Promise<number>;
|
||||
var newPromise = numPromise.then(testFunction);
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
|
||||
module m6 {
|
||||
interface Promise<T> {
|
||||
then<U>(cb: (x: T) => Promise<U>): Promise<U>;
|
||||
then<U>(cb: (x: T) => Promise<U>, error?: (error: any) => Promise<U>): Promise<U>;
|
||||
}
|
||||
|
||||
declare function testFunction(n: number): Promise<number>;
|
||||
declare function testFunction(s: string): Promise<string>;
|
||||
declare function testFunction(b: boolean): Promise<boolean>;
|
||||
|
||||
var numPromise: Promise<number>;
|
||||
var newPromise = numPromise.then(testFunction);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user