automatic typescript badbaado isku duwidda ee Visual Studio Code

In this post aan xallin doonaan laba dhibaato: 1) amarka “TSC” Waxaa la ma aqoonsan yahay in terminal isku dhafan ee code VS, e 2) isku duwidda xogta aanu si toos ah u shaqeeyaan marka lagu badbaadinayo file “.TS” (Ku qor qoraalka showga).

sal-dhigida

Just in xaaladda la waafajiyo, ah TypeScript Waxay kuu ogolaanaysaa inaad si ay u qoraan code isticmaalaya qaab si adag ku qortay oo ku code this ururisey in JavaScript saafi ah. horay Visual Studio Code Waa editor code cross-madal a abuuray by Microsoft.

// Qoraalkii loo isticmaalo Post this:
- Studio Visual (VS) Code: version 1.14.1
- Typescript: version 2.4.1

Tani waa tip fudud, laakiin waxaa laga yaabaa in aad qabto dhibaatooyin haddii aadan aqoon waxa aad qabanayso: kiiskeyga :D

Node.js iyo rakibaadda typescript

Mid ka mid ah habka si loo soo dajiyo waa typescript dhex Tababaraha xirmo Node.js (ASL – Tababaraha xirmo Guntin), muddo ka isticmaalaya-eeg, in aad marka hore u baahan rakibi Node.js.

Ka dib markii ay ku rakibidda Noode ah, furan ama terminal (amarka) oo ay maamulaan amarka soo socda si aad rakibi typescript:

npm rakibi -g typescript

Inkasta oo Terminal Windows (ama Linux), dhigi baxsad imtixaanka of typescript ah hubinta version rakibay. amarka “TSC” Waa gaabinta ah Compiler typescript.

TSC -v

dhibaato

Dhibaatada waxa ay tahay in amarka “TSC” Waxaa si caadi ah u shaqeeyay ee Windows Terminal, laakiin ma aha in terminal ee isku dhafan ee Visual Studio Code laftiisa soo socda (VS code), soo bandhigeen baadi soo socda:

'TSC' aan la aqoonsan yahay sida Amarka ah gudaha ama dibadda,Barnaamijka buuxsan Dufcaddii file.

Oo weliba, Ma aanan rabin in uu ordo amarka “TSC” waayo, mar kasta waxaan doonayay inay isku ururiso file a “.TS” (kordhin waayo typescript). ka dibna, sida had iyo jeer ka dhigi badbaado isku duwidda xogta automatic (Ctrl + S)? Tani waa waxa aan arki doonaan.

qaladaad kale

Xallinta dhibaatooyinkan, Posts waxaan ka helay oo ku yidhi in ay isticmaalaan compileOnSave, laakiin tani waxaa lagu taageeray oo kaliya by Studio Visual 2015 com TypeScript> = 1.8.4 e plugin eb-typescript. in si kale loo dhigo, ma isticmaalka wanaagsan compileOnSave no “tsconfig.json” samayn Visual Studio Code, code hoose ma shaqeyn doono:

{
   "compileOnSave": run,
   "compilerOptions": {
       "noImplicitAny" : run
   }
}

xal

TSC ee Terminal VS Xeerka dhafan

Marka hore waxaan u xaliyaan dhibaatada of TSC in aan la aqoonsan yahay ee terminal ee isku dhafan ee Studio Xeerka Visual (VS code).

qaar ka mid ah posts Waxay soo jeedinaynaa in gelinaya Jidka tsk ama npm in variable deegaanka PATH ah, laakiin si fudud ayaa looga this xal u sameeynayay rakibidda “TypeScript for Studio Visual, taas oo socon waayo VS Code sidoo kale.

hadda haa, ka dib markii la rakibey, furo guddi hawlgalka Studio Xeerka Muuqaal ah, Teclando:

// muhiimka ah toobiye for terminal ee isku dhafan ee Studio Xeerka Visual:
Ctrl+`
// Ama isticmaal menu ah in la furo terminal ee Visual Studio Code:
view > Integrated Terminal

Isku day in aad hubiso version of typescript ah toosiyo terminal ka midaysan VS Code (Ma aha in Windows Terminal), iyo doonaa malaha la shaqeeya:

TSC -v

isku duwidda xogta si toos ah marka lagu badbaadinayo file a .TS

By terminal ka VS Code waa jago ee buugga tusaha script aad (.TS), tusaale ahaan:

cd C:\wamp64  www  TS

Abuur faylka tsconfig.json by teeb in VS Xeerka terminal:

TSC --init

Ogsoonow in file a “tsconfig.json” Waxaa la abuuri doonaa in “C:\wamp64 www TS” (tusaha hadda).

Wuxuu furaa tsconfig.json iyo awood ikhtiyaarka “sourceMap”: run, iyo badbaadin isbedelka, helitaanka iyo sidoo kale:

  "compilerOptions": {
    /* Options aasaasiga ah */
    "target": "es5",                          /* Sheeg version diirada ECMAScript: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', ama 'ESNEXT'. */
    "module": "commonjs",                     /* Sheeg jiilka code module: 'Commonjs', 'AMD', 'Nidaamka', 'Umd', 'Es2015', ama 'ESNext'. */
    // "lib": [],                             /* Sheeg files maktabadda in lagu daro isku duwidda:  */
    // "allowJs": run,                       /* U ogolow files javascript in la soo ururiyey. */
    // "checkJs": run,                       /* khaladaadka Report in files .js. */
    // "jsx": "preserve",                     /* Sheeg jiilka code JSX: 'Loo ilaalin', 'Fal-hooyo', ama 'fal'. */
    // "declaration": run,                   /* Taliyaha Guud ee baahisey file '.d.ts'. */
    "sourceMap": run,                     /* Taliyaha Guud ee baahisey file '.map'. */
    // "outFile": "./",                       /* Concatenate oo dhaadheer wax soo saarka si ay u file hal. */
    // "outDir": "./",                        /* Isugeeyey dhismeedka wax soo saarka si ay tusaha. */
    // "rootDir": "./",                       /* Sheeg buugga asalka u ah files talooyin ah. Isticmaal in la xakameeyo qaab-dhismeedka buugga soo saarka la --outDir. */
    ... sii ...

ugu dhakhsaha badan, Hadda waxaad uun in terminal ka VS Code tago oo ku qor amarka:

TSC -w

Amarkani waxa uu yahay la socodka (ama daawashada, Sidaa darteed “w” gaadhka) codsiga iyo wixii isbeddel ah ee files .TS, marka waan badbaadin, doono isku duwidda degdeg ah .JS.

In ay!

Total Furidda: 9221

Leave a Reply

cinwaanka email Your aan laga soo saari doonaa. Beeraha loo baahan yahay waxaa lagu calaamadeeyay la *