Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // FooData型とBarData型の値を流すことを考えてみる
- interface FooData {
- foo: string;
- }
- interface BarData {
- bar: number;
- }
- // 3秒後に2つのデータを流す
- new Promise<{ data1: FooData, data2: BarData }>(resolve => {
- setTimeout(() => {
- resolve({
- data1: {foo: "boy"},
- data2: {bar: 2}
- });
- }, 3000);
- })
- .then(result => console.log(result.data1.foo, result.data2.bar));
- // boy, 2が出力される
Add Comment
Please, Sign In to add comment