Typescript Migration JS To TS Step By Step
Ringkasan
TS kompatibel dengan JS. Migrasi bisa bertahap: jalankan TS di samping JS, lalu perketat tipe pelan-pelan.
Konsep Dasar
- Install:
npm i -D typescript. - Buat
tsconfig.jsondengan"allowJs": trueagar file.jstetap jalan. - Ganti ekstensi
.js→.tssatu per satu. - Tambah
// @ts-checkataucheckJsuntuk cek file JS tanpa convert. - Naikkan strictness bertahap (lihat post terkait).
Cara Kerja / Struktur
// tsconfig.json (awal ramah migrasi)
{
"compilerOptions": {
"allowJs": true,
"checkJs": false,
"noEmit": true,
"strict"