Skip to content

Commit 1d18136

Browse files
committed
Adding tests
1 parent bf97250 commit 1d18136

7 files changed

Lines changed: 2338 additions & 0 deletions
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
tests/cases/compiler/bluebirdStaticThis.ts(5,15): error TS2420: Class 'Promise<R>' incorrectly implements interface 'Thenable<R>'.
2+
Property 'then' is missing in type 'Promise<R>'.
3+
tests/cases/compiler/bluebirdStaticThis.ts(22,51): error TS2305: Module 'Promise' has no exported member 'Resolver'.
4+
tests/cases/compiler/bluebirdStaticThis.ts(57,109): error TS2305: Module 'Promise' has no exported member 'Inspection'.
5+
tests/cases/compiler/bluebirdStaticThis.ts(58,91): error TS2305: Module 'Promise' has no exported member 'Inspection'.
6+
tests/cases/compiler/bluebirdStaticThis.ts(59,91): error TS2305: Module 'Promise' has no exported member 'Inspection'.
7+
tests/cases/compiler/bluebirdStaticThis.ts(60,73): error TS2305: Module 'Promise' has no exported member 'Inspection'.
8+
9+
10+
==== tests/cases/compiler/bluebirdStaticThis.ts (6 errors) ====
11+
// This version is reduced from the full d.ts by removing almost all the tests
12+
// and all the comments.
13+
// Then it adds explicit `this` arguments to the static members.
14+
// Tests by: Bart van der Schoor <https://github.com/Bartvds>
15+
declare class Promise<R> implements Promise.Thenable<R> {
16+
~~~~~~~
17+
!!! error TS2420: Class 'Promise<R>' incorrectly implements interface 'Thenable<R>'.
18+
!!! error TS2420: Property 'then' is missing in type 'Promise<R>'.
19+
constructor(callback: (resolve: (thenableOrResult: R | Promise.Thenable<R>) => void, reject: (error: any) => void) => void);
20+
static try<R>(dit: typeof Promise, fn: () => Promise.Thenable<R>, args?: any[], ctx?: any): Promise<R>;
21+
static try<R>(dit: typeof Promise, fn: () => R, args?: any[], ctx?: any): Promise<R>;
22+
23+
static attempt<R>(dit: typeof Promise, fn: () => Promise.Thenable<R>, args?: any[], ctx?: any): Promise<R>;
24+
static attempt<R>(dit: typeof Promise, fn: () => R, args?: any[], ctx?: any): Promise<R>;
25+
26+
static method(dit: typeof Promise, fn: Function): Function;
27+
28+
static resolve(dit: typeof Promise): Promise<void>;
29+
static resolve<R>(dit: typeof Promise, value: Promise.Thenable<R>): Promise<R>;
30+
static resolve<R>(dit: typeof Promise, value: R): Promise<R>;
31+
32+
static reject(dit: typeof Promise, reason: any): Promise<any>;
33+
static reject<R>(dit: typeof Promise, reason: any): Promise<R>;
34+
35+
static defer<R>(dit: typeof Promise): Promise.Resolver<R>;
36+
~~~~~~~~
37+
!!! error TS2305: Module 'Promise' has no exported member 'Resolver'.
38+
39+
static cast<R>(dit: typeof Promise, value: Promise.Thenable<R>): Promise<R>;
40+
static cast<R>(dit: typeof Promise, value: R): Promise<R>;
41+
42+
static bind(dit: typeof Promise, thisArg: any): Promise<void>;
43+
44+
static is(dit: typeof Promise, value: any): boolean;
45+
46+
static longStackTraces(dit: typeof Promise): void;
47+
48+
static delay<R>(dit: typeof Promise, value: Promise.Thenable<R>, ms: number): Promise<R>;
49+
static delay<R>(dit: typeof Promise, value: R, ms: number): Promise<R>;
50+
static delay(dit: typeof Promise, ms: number): Promise<void>;
51+
52+
static promisify(dit: typeof Promise, nodeFunction: Function, receiver?: any): Function;
53+
54+
static promisifyAll(dit: typeof Promise, target: Object): Object;
55+
56+
static coroutine<R>(dit: typeof Promise, generatorFunction: Function): Function;
57+
58+
static spawn<R>(dit: typeof Promise, generatorFunction: Function): Promise<R>;
59+
60+
static noConflict(dit: typeof Promise): typeof Promise;
61+
62+
static onPossiblyUnhandledRejection(dit: typeof Promise, handler: (reason: any) => any): void;
63+
64+
static all<R>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>): Promise<R[]>;
65+
static all<R>(dit: typeof Promise, values: Promise.Thenable<R[]>): Promise<R[]>;
66+
static all<R>(dit: typeof Promise, values: Promise.Thenable<R>[]): Promise<R[]>;
67+
static all<R>(dit: typeof Promise, values: R[]): Promise<R[]>;
68+
69+
static props(dit: typeof Promise, object: Promise<Object>): Promise<Object>;
70+
static props(dit: typeof Promise, object: Object): Promise<Object>;
71+
72+
static settle<R>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>): Promise<Promise.Inspection<R>[]>;
73+
~~~~~~~~~~
74+
!!! error TS2305: Module 'Promise' has no exported member 'Inspection'.
75+
static settle<R>(dit: typeof Promise, values: Promise.Thenable<R[]>): Promise<Promise.Inspection<R>[]>;
76+
~~~~~~~~~~
77+
!!! error TS2305: Module 'Promise' has no exported member 'Inspection'.
78+
static settle<R>(dit: typeof Promise, values: Promise.Thenable<R>[]): Promise<Promise.Inspection<R>[]>;
79+
~~~~~~~~~~
80+
!!! error TS2305: Module 'Promise' has no exported member 'Inspection'.
81+
static settle<R>(dit: typeof Promise, values: R[]): Promise<Promise.Inspection<R>[]>;
82+
~~~~~~~~~~
83+
!!! error TS2305: Module 'Promise' has no exported member 'Inspection'.
84+
85+
static any<R>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>): Promise<R>;
86+
static any<R>(dit: typeof Promise, values: Promise.Thenable<R[]>): Promise<R>;
87+
static any<R>(dit: typeof Promise, values: Promise.Thenable<R>[]): Promise<R>;
88+
static any<R>(dit: typeof Promise, values: R[]): Promise<R>;
89+
90+
static race<R>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>): Promise<R>;
91+
static race<R>(dit: typeof Promise, values: Promise.Thenable<R[]>): Promise<R>;
92+
static race<R>(dit: typeof Promise, values: Promise.Thenable<R>[]): Promise<R>;
93+
static race<R>(dit: typeof Promise, values: R[]): Promise<R>;
94+
95+
static some<R>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>, count: number): Promise<R[]>;
96+
static some<R>(dit: typeof Promise, values: Promise.Thenable<R[]>, count: number): Promise<R[]>;
97+
static some<R>(dit: typeof Promise, values: Promise.Thenable<R>[], count: number): Promise<R[]>;
98+
static some<R>(dit: typeof Promise, values: R[], count: number): Promise<R[]>;
99+
100+
static join<R>(dit: typeof Promise, ...values: Promise.Thenable<R>[]): Promise<R[]>;
101+
static join<R>(dit: typeof Promise, ...values: R[]): Promise<R[]>;
102+
103+
static map<R, U>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable<U>): Promise<U[]>;
104+
static map<R, U>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>, mapper: (item: R, index: number, arrayLength: number) => U): Promise<U[]>;
105+
static map<R, U>(dit: typeof Promise, values: Promise.Thenable<R[]>, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable<U>): Promise<U[]>;
106+
static map<R, U>(dit: typeof Promise, values: Promise.Thenable<R[]>, mapper: (item: R, index: number, arrayLength: number) => U): Promise<U[]>;
107+
static map<R, U>(dit: typeof Promise, values: Promise.Thenable<R>[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable<U>): Promise<U[]>;
108+
static map<R, U>(dit: typeof Promise, values: Promise.Thenable<R>[], mapper: (item: R, index: number, arrayLength: number) => U): Promise<U[]>;
109+
static map<R, U>(dit: typeof Promise, values: R[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable<U>): Promise<U[]>;
110+
static map<R, U>(dit: typeof Promise, values: R[], mapper: (item: R, index: number, arrayLength: number) => U): Promise<U[]>;
111+
112+
static reduce<R, U>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable<U>, initialValue?: U): Promise<U>;
113+
static reduce<R, U>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
114+
115+
static reduce<R, U>(dit: typeof Promise, values: Promise.Thenable<R[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable<U>, initialValue?: U): Promise<U>;
116+
static reduce<R, U>(dit: typeof Promise, values: Promise.Thenable<R[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
117+
118+
static reduce<R, U>(dit: typeof Promise, values: Promise.Thenable<R>[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable<U>, initialValue?: U): Promise<U>;
119+
static reduce<R, U>(dit: typeof Promise, values: Promise.Thenable<R>[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
120+
121+
static reduce<R, U>(dit: typeof Promise, values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable<U>, initialValue?: U): Promise<U>;
122+
static reduce<R, U>(dit: typeof Promise, values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
123+
124+
static filter<R>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<R[]>;
125+
static filter<R>(dit: typeof Promise, values: Promise.Thenable<Promise.Thenable<R>[]>, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise<R[]>;
126+
static filter<R>(dit: typeof Promise, values: Promise.Thenable<R[]>, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<R[]>;
127+
static filter<R>(dit: typeof Promise, values: Promise.Thenable<R[]>, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise<R[]>;
128+
static filter<R>(dit: typeof Promise, values: Promise.Thenable<R>[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<R[]>;
129+
static filter<R>(dit: typeof Promise, values: Promise.Thenable<R>[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise<R[]>;
130+
static filter<R>(dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<R[]>;
131+
static filter<R>(dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise<R[]>;
132+
}
133+
134+
declare module Promise {
135+
export interface Thenable<R> {
136+
then<U>(onFulfilled: (value: R) => Thenable<U>, onRejected: (error: any) => Thenable<U>): Thenable<U>;
137+
then<U>(onFulfilled: (value: R) => Thenable<U>, onRejected?: (error: any) => U): Thenable<U>;
138+
then<U>(onFulfilled: (value: R) => U, onRejected: (error: any) => Thenable<U>): Thenable<U>;
139+
then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): Thenable<U>;
140+
}
141+
142+
}
143+
144+
declare module 'bluebird' {
145+
export = Promise;
146+
}
147+
interface Foo {
148+
a: number;
149+
b: string;
150+
}
151+
var x: any;
152+
var arr: any[];
153+
var foo: Foo;
154+
var fooProm: Promise<Foo>;
155+
156+
fooProm = Promise.try(Promise, () => {
157+
return foo;
158+
});
159+
fooProm = Promise.try(Promise, () => {
160+
return foo;
161+
}, arr);
162+
fooProm = Promise.try(Promise, () => {
163+
return foo;
164+
}, arr, x);

0 commit comments

Comments
 (0)