【Node.js + TypeScript】エラー「TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.」の対処法


「npx tsc index.ts」等のコマンドでjsファイルを生成しますが、以下のエラーが発生することがありました。

TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.

調べると、tsconfig.jsonを変更するとか出てきますが、解決にはなりません。

原因と対処法

そもそも、「npx tsc index.ts」等の個別にファイル指定する場合、tsconfig.jsonが無視されてしまうそうです。

そのため、「npx tsc」のように一括で変換すれば大丈夫です。