-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8777657
commit e6c676e
Showing
5 changed files
with
178 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...rence/convertToAsyncFunction/convertToAsyncFunction_CatchFollowedByThenMismatchTypes02.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// ==ORIGINAL== | ||
|
||
function /*[#|*/f/*|]*/(){ | ||
return fetch("https://typescriptlang.org").then(res).catch(rej).then(res); | ||
} | ||
|
||
function res(result){ | ||
return 5; | ||
} | ||
|
||
function rej(reject): Response{ | ||
return reject; | ||
} | ||
|
||
// ==ASYNC FUNCTION::Convert to async function== | ||
|
||
async function f(){ | ||
let result: number | Response; | ||
try { | ||
const result_1 = await fetch("https://typescriptlang.org"); | ||
result = await res(result_1); | ||
} | ||
catch (reject) { | ||
result = await rej(reject); | ||
} | ||
return res(result); | ||
} | ||
|
||
function res(result){ | ||
return 5; | ||
} | ||
|
||
function rej(reject): Response{ | ||
return reject; | ||
} |
35 changes: 35 additions & 0 deletions
35
...ToAsyncFunction/convertToAsyncFunction_CatchFollowedByThenMismatchTypes02NoAnnotations.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// ==ORIGINAL== | ||
|
||
function /*[#|*/f/*|]*/(){ | ||
return fetch("https://typescriptlang.org").then(res).catch(rej).then(res); | ||
} | ||
|
||
function res(result){ | ||
return 5; | ||
} | ||
|
||
function rej(reject){ | ||
return reject; | ||
} | ||
|
||
// ==ASYNC FUNCTION::Convert to async function== | ||
|
||
async function f(){ | ||
let result; | ||
try { | ||
const result_1 = await fetch("https://typescriptlang.org"); | ||
result = await res(result_1); | ||
} | ||
catch (reject) { | ||
result = await rej(reject); | ||
} | ||
return res(result); | ||
} | ||
|
||
function res(result){ | ||
return 5; | ||
} | ||
|
||
function rej(reject){ | ||
return reject; | ||
} |
35 changes: 35 additions & 0 deletions
35
...ToAsyncFunction/convertToAsyncFunction_CatchFollowedByThenMismatchTypes02NoAnnotations.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// ==ORIGINAL== | ||
|
||
function /*[#|*/f/*|]*/(){ | ||
return fetch("https://typescriptlang.org").then(res).catch(rej).then(res); | ||
} | ||
|
||
function res(result){ | ||
return 5; | ||
} | ||
|
||
function rej(reject){ | ||
return reject; | ||
} | ||
|
||
// ==ASYNC FUNCTION::Convert to async function== | ||
|
||
async function f(){ | ||
let result: any; | ||
try { | ||
const result_1 = await fetch("https://typescriptlang.org"); | ||
result = await res(result_1); | ||
} | ||
catch (reject) { | ||
result = await rej(reject); | ||
} | ||
return res(result); | ||
} | ||
|
||
function res(result){ | ||
return 5; | ||
} | ||
|
||
function rej(reject){ | ||
return reject; | ||
} |
55 changes: 55 additions & 0 deletions
55
...rence/convertToAsyncFunction/convertToAsyncFunction_CatchFollowedByThenMismatchTypes04.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// ==ORIGINAL== | ||
|
||
interface a { | ||
name: string; | ||
age: number; | ||
} | ||
|
||
interface b extends a { | ||
color: string; | ||
} | ||
|
||
|
||
function /*[#|*/f/*|]*/(){ | ||
return fetch("https://typescriptlang.org").then(res).catch(rej).then(res); | ||
} | ||
|
||
function res(result): b{ | ||
return {name: "myName", age: 22, color: "red"}; | ||
} | ||
|
||
function rej(reject): a{ | ||
return {name: "myName", age: 27}; | ||
} | ||
|
||
// ==ASYNC FUNCTION::Convert to async function== | ||
|
||
interface a { | ||
name: string; | ||
age: number; | ||
} | ||
|
||
interface b extends a { | ||
color: string; | ||
} | ||
|
||
|
||
async function f(){ | ||
let result: a; | ||
try { | ||
const result_1 = await fetch("https://typescriptlang.org"); | ||
result = await res(result_1); | ||
} | ||
catch (reject) { | ||
result = await rej(reject); | ||
} | ||
return res(result); | ||
} | ||
|
||
function res(result): b{ | ||
return {name: "myName", age: 22, color: "red"}; | ||
} | ||
|
||
function rej(reject): a{ | ||
return {name: "myName", age: 27}; | ||
} |