下記コードはnode test02.jsでエラーなく実行できます。
javascript
1//ファイル名 test02.js 2function repeatHello(count) { 3 return "hello".repeat(count); 4} 5console.log(repeatHello(2));
これを下記に変更してVSCodeでデバックしようとするとrepeatのところに赤い波線が表示され
Property 'repeat' does not exist on type '"hello"'.
というエラーになります。間違いが分かりません。どうしてでしょうか?
typescript
1function repeatHello(count:number):string { 2 return "hello".repeat(count); 3} 4console.log(repeatHello(2));
回答1件
あなたの回答
tips
プレビュー