microsoft / microsoft/TypeScript
tsc includes previous output in result when allowJs is enabled and "exclude" is non-empty
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
TypeScript Version: 2.7.0-dev.20171222
Code
For easy access, clone this gist: https://gist.github.com/WasabiFan/6922d6eb6224945ac809c216fdc37089
test.ts:
// Source code here
tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"outDir": "out",
"allowJs": true
},
"exclude": [
"node_modules"
]
}
Removing the exclude block or disabling allowJs avoids the issue.
Note that this is an easy state to get into: in my case, I generated a VSCode extension with their official templates and then enabled allowJs. I didn't realize what was going on until my PC ran out of RAM, as it automatically ran the watch task and the depth grew every time I saved.
Expected behavior:
I can compile the project with tsc as many times as I'd like.
Actual behavior:
PS D:\...> git clone https://gist.github.com/WasabiFan/6922d6eb6224945ac809c216fdc37089 tsc-recursion-demo-gist
Cloning into 'tsc-recursion-demo-gist'...
remote: Counting objects: 7, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 7 (delta 1), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (7/7), done.
PS D:\...> cd .\tsc-recursion-demo-gist\
PS D:\...\tsc-recursion-demo-gist> tsc -p .
PS D:\...\tsc-recursion-demo-gist> tsc -p .
error TS5055: Cannot write file 'D:/.../tsc-recursion-demo-gist/out/test.js' because it would overwrite input file.
PS D:\...\tsc-recursion-demo-gist> tsc -p .
error TS5055: Cannot write file 'D:/.../tsc-recursion-demo-gist/out/out/test.js' because it would overwrite input file.
error TS5055: Cannot write file 'D:/.../tsc-recursion-demo-gist/out/test.js' because it would overwrite input file.
PS D:\...\tsc-recursion-demo-gist> tsc -p .
error TS5055: Cannot write file 'D:/.../tsc-recursion-demo-gist/out/out/out/test.js' because it would overwrite input file.
error TS5055: Cannot write file 'D:/.../tsc-recursion-demo-gist/out/out/test.js' because it would overwrite input file.
error TS5055: Cannot write file 'D:/.../tsc-recursion-demo-gist/out/test.js' because it would overwrite input file.
PS D:\...\tsc-recursion-demo-gist> tsc -p .
error TS5055: Cannot write file 'D:/.../tsc-recursion-demo-gist/out/out/out/out/test.js' because it would overwrite input file.
error TS5055: Cannot write file 'D:/.../tsc-recursion-demo-gist/out/out/out/test.js' because it would overwrite input file.
error TS5055: Cannot write file 'D:/.../tsc-recursion-demo-gist/out/out/test.js' because it would overwrite input file.
error TS5055: Cannot write file 'D:/.../tsc-recursion-demo-gist/out/test.js' because it would overwrite input file.
PS D:\...\tsc-recursion-demo-gist> tsc -p .
error TS5055: Cannot write file 'D:/.../tsc-recursion-demo-gist/out/out/out/out/out/test.js' because it would overwrite input file.
error TS5055: Cannot write file 'D:/.../tsc-recursion-demo-gist/out/out/out/out/test.js' because it would overwrite input file.
error TS5055: Cannot write file 'D:/.../tsc-recursion-demo-gist/out/out/out/test.js' because it would overwrite input file.
error TS5055: Cannot write file 'D:/.../tsc-recursion-demo-gist/out/out/test.js' because it would overwrite input file.
error TS5055: Cannot write file 'D:/.../tsc-recursion-demo-gist/out/test.js' because it would overwrite input file.
The fix (and the best option) is to exclude the output directory. But given that existing templates don't do that, I think this is a significant issue. I don't understand why this doesn't happen when the exclude block is removed; I assume there's an internal safety to prevent this problem that's overridden.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Clona il gist collegato e riproduci il problema con test.ts e tsconfig.json, usando allowJs, un exclude non vuoto e outDir. Inizia tracciando l'individuazione degli input del progetto e il comportamento delle esecuzioni ripetute di tsc -p. Il lavoro è completato quando le compilazioni ripetute non includono più gli output precedenti sotto out/ come nuovi input né producono percorsi di output ricorsivi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, typescript
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 30/100