← TypeScript38 / 43
Migrasi File JS ke TS Bertahap
Strategi migrasi JS ke TS: ubah ekstensi .js ke .ts, lalu gunakan allowJs: true di tsconfig untuk bertahap menambahkan anotasi tipe.
👀 Contoh dulu
// tsconfig.json
{ "compilerOptions": { "allowJs": true } }Hasilnya: { "compilerOptions": { "allowJs": true } }
💡 Jangan mencoba mengubah seluruh file JS sekaligus dalam satu PR.
📝 Sekarang giliranmu
Di dalam file tsconfig.json pada bagian compilerOptions, tambahkan properti untuk mengizinkan file JavaScript (.js) dikompilasi bersama proyek TypeScript.
Preview