回答編集履歴
1
キャストする方法もあることを追記
answer
CHANGED
@@ -11,4 +11,9 @@
|
|
11
11
|
const arr: string[] = [];
|
12
12
|
|
13
13
|
const index = arr.indexOf("kero");
|
14
|
+
```
|
15
|
+
|
16
|
+
もしくは、下記のように、その場で型付きの配列にキャストする方法もあります。
|
17
|
+
```typescript
|
18
|
+
const index = ([] as string[]).indexOf("kero");
|
14
19
|
```
|