Skip to content

Commit eea6c97

Browse files
committed
Fix ES6 Promise typings so that a void error callback does not mess up inference
1 parent 557bb59 commit eea6c97

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

es6-promise/es6-promise-tests.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,32 @@ getJSON('story.json').then(function(story: Story) {
160160
}).then(function() {
161161
(<HTMLElement>document.querySelector('.spinner')).style.display = 'none';
162162
});
163+
164+
interface T1 {
165+
__t1: string;
166+
}
167+
168+
interface T2 {
169+
__t2: string;
170+
}
171+
172+
interface T3 {
173+
__t3: string;
174+
}
175+
176+
function f1(): Promise<T1> {
177+
return Promise.resolve({ __t1: "foo_t1" });
178+
}
179+
180+
function f2(x: T1): T2 {
181+
return { __t2: x.__t1 + ":foo_21" };
182+
}
183+
184+
var x3 = f1()
185+
.then(f2, (e: Error) => {
186+
console.log("error 1");
187+
throw e;
188+
})
189+
.then((x: T2) => {
190+
return { __t3: x.__t2 + "bar" };
191+
});

0 commit comments

Comments
 (0)