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