Jagoran mataki-mataki don Haɗawa TypeScript
cikin JavaScript
Ayyukan da ke da:
Mataki 1: Shigar TypeScript
Amfani npm
ko yarn
zuwa install TypeScript:
npm install -g typescript
ko yarn global add typescript
.
Mataki 2: Ƙirƙiri TypeScript
Fayil na Kanfigareshan
- Ƙirƙiri
tsconfig.json
fayil a tushen tushen aikin ku:tsc --init
. - A cikin
tsconfig.json
fayil ɗin, saita zaɓuɓɓuka kamartarget
,module
,outDir
da kumainclude
gwargwadon bukatun aikin ku.
Mataki 2: Ƙirƙiri TypeScript
Fayil na Kanfigareshan
- Ƙirƙiri
tsconfig.json
fayil a tushen tushen aikin ku:tsc --init
. - A cikin
tsconfig.json
fayil ɗin, saita zaɓuɓɓuka kamartarget
,module
,outDir
da kumainclude
gwargwadon bukatun aikin ku.
Mataki 3: Maida JavaScript
Files zuwa TypeScript
- Sake suna
.js
fayiloli zuwa.ts
ga dukJavaScript
fayilolin da ke cikin aikin ku. - Yi amfani
TypeScript
da syntax don inganta lambar kuma ƙara nau'in bayanin yadda ake buƙata.
Mataki 4: Gina TypeScript
Aikin
- Gudun
tsc
umarni kotsc -w
don haɗaTypeScript
fayilolin zuwaJavaScript
lambar da ta dace. - Tabbatar cewa
JavaScript
an ƙirƙira fayilolin kuma an tsara su daidai daidai da daidaitawa a cikintsconfig.json
.
Mataki na 5: Magance al'amura gama gari
- Bincika
TypeScript
kurakuran tattarawa kuma a warware su daidai. - Magance kowace matsala tare da bayyananniyar nau'in da ba a bayyana ba a cikin aikin ku.
- Tabbatar da dacewa da ɗakunan karatu da tsarin da aka yi amfani da su a cikin aikin JavaScript tare da
TypeScript
.
Lura: Yayin TypeScript
aikin haɗin kai, ƙila ku gamu da al'amura na gama gari da kurakurai kamar nau'in rashin daidaituwa, kwafi, ko daidaitawar da ba daidai ba. Yi haƙuri kuma koma zuwa TypeScript
takardu ko al'umma don magance waɗannan batutuwa.
Haɗa TypeScript cikin JavaScript
aikin da ake da shi na iya kawo fa'idodi da yawa, kamar ingantaccen aminci, sauƙin sarrafa lambar, da goyan baya ga sabbin fasalulluka da TypeScript
.