2015-05-18 8 views
10

Sto usando codice ID studio visivo e dattiloscritto, come faccio a ignorare la cartella node_modules durante la compilazione? O hai creato i file .ts al salvataggio? Mostra molti errori perché sta cercando di compilare node_modules tsd.Come ignorare la cartella `node_modules` durante la creazione di TypeScript in VSCode

Attualmente la mia tasks.json è

{ 
    "version": "0.1.0", 

    // The command is tsc. 
    "command": "tsc", 

    // Show the output window only if unrecognized errors occur. 
    "showOutput": "silent", 

    // Under windows use tsc.exe. This ensures we don't need a shell. 
    "windows": { 
     "command": "tsc.exe" 
    }, 

    "isShellCommand": true, 

    // args is the HelloWorld program to compile. 
    "args": [], 



    // use the standard tsc problem matcher to find compile problems 
    // in the output. 
    "problemMatcher": "$tsc" 
} 

risposta

6

Se non si fornisce un elenco di file, codice verrà compilato tutti.

{ 
    "compilerOptions": { 
     "target": "ES5" 
    } 
} 

È possibile modificare questo fornendo solo i file che si desidera compilare.

{ 
    "compilerOptions": { 
     "target": "ES6" 
    }, 
    "files": [ 
     "app.ts", 
     "other.ts", 
     "more.ts" 
    ] 
} 

Codice Speriamo che sarà presto sostenere filesGlob, che consente di utilizzare i modelli per afferrare tutti i file da determinate cartelle, il che significa che non sarà necessario creare un elenco dettagliato di tutti i file.

20

Nella versione 0.5 è possibile hide files and folders

Aprire file-> Preferenze> Impostazioni utente e aggiungere qualcosa di simile

{ 
     "files.exclude": { 
      "**/.git": true, 
      "**/.DS_Store": true, 
      "jspm_packages" : true, 
      "node_modules" : true 
     } 
} 
+0

Questo non è il caso, questo solo esclude dalla vista che nascondono la cartella che non lo nasconde dal compilatore tsc. – httpete

+13

Sì, non la risposta alla domanda ma esattamente quello che stavo cercando! Forse dovresti postarlo come una nuova domanda;) – jluna

0

Ecco un modo per farti da parte, non utilizzare TSconfig .json per ora non supporta esclude di cui avrai bisogno. Quello che voglio è semplicemente compilare il file con le opzioni usando tasks.json. Per ora devi CTRL + MAIUSC + B per costruire, non c'è un modo carino per costruire ancora con il salvataggio.

{ 

"version": "0.1.0", 

// The command is tsc. Assumes that tsc has been installed using npm install -g typescript 
"command": "tsc", 

// The command is a shell script 
"isShellCommand": true, 

// Show the output window only if unrecognized errors occur. 
"showOutput": "always", 

// args is the HelloWorld program to compile. 
"args": ["${file}", "--module", "amd", "--target", "ES5"], 


// use the standard tsc problem matcher to find compile problems 
// in the output. 
"problemMatcher": "$tsc" 

}