質問編集履歴

3

補足

2022/06/25 10:54

投稿

noc
noc

スコア73

test CHANGED
File without changes
test CHANGED
@@ -1,7 +1,7 @@
1
1
  型がわからない関数について、特定の呼び出しシグネチャを持つことを確認することはできますか?
2
2
  下記の例で言うと `mod.execute` は `(a: string, b: number) => [boolean, string]` という型を持つことを確認して、もし違ったならエラーを発生させたいのですが。
3
3
  ```typescript
4
- const mod = await import('/home/foo/mod.ts')
4
+ const mod = await import('/home/foo/mod.ts') // 動的インポート(foo/mod.ts には execute() という関数が定義され export されている)
5
5
  if ('execute' in mod && typeof mod.execute === 'function'){
6
6
  const execute: (a: string, b: number) => [boolean, string] = mod.execute
7
7
  let [doFinish, str]: [boolean, string] = execute('string', 1)

2

題名変更

2022/06/25 10:52

投稿

noc
noc

スコア73

test CHANGED
@@ -1 +1 @@
1
- 関数の型が特定の型であることを確認(保証)する方法はありますか?
1
+ 関数の型が特定の型であることを確認する(保証させる)方法はありますか?
test CHANGED
File without changes

1

題名変更

2022/06/25 10:51

投稿

noc
noc

スコア73

test CHANGED
@@ -1 +1 @@
1
- 関数の型が特定の型であることを確認する方法はありますか?
1
+ 関数の型が特定の型であることを確認(保証)する方法はありますか?
test CHANGED
File without changes