microsoft / microsoft/TypeScript
TypeScript skips type-checking despite deleted file in referenced project
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
Acknowledgement
- I acknowledge that issues using this template may be closed without further explanation at the maintainer's discretion.
Comment
We have encountered an unusual case in our project references setup. Below is a description of the current configuration. I believe there might be a gap in our setup or configuration that is causing this issue.
Setup
- We have two projects: 'bar' and 'foo'
- 'foo' references 'bar'
- 'foo/src/index2.ts' consumes a function from "bar/clean" (The entry point is created using TypeScript paths at the repo root tsconfig)
- 'tsconfig.project-references.json' at the repo root is our solution file, containing links to the projects
- Base tsconfig
{
"compilerOptions": {
"baseUrl": "./",
"outDir": "out-tsc/frontend/base",
"incremental": true,
"composite": true,
"target": "ES2020",
"lib": ["ES2022", "DOM"],
"jsx": "react",
"jsxFactory": "React.createElement",
"jsxFragmentFactory": "React.Fragment",
"types": [],
"module": "ESNext",
"moduleResolution": "Node10",
"resolveJsonModule": true,
"importHelpers": true,
"isolatedModules": false,
"allowSyntheticDefaultImports": true,
"allowImportingTsExtensions": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noFallthroughCasesInSwitch": true,
"skipLibCheck": true,
"experimentalDecorators": false,
"verbatimModuleSyntax": true,
"emitDeclarationOnly": true,
"paths": {
"bar/clean": ["packages/bar/src/clean.ts"]
}
}
}
Steps to reproduce the issue
-
Run TypeScript build with project references. This should create a 'tsDist' folder at the repo root with emitted declarations:
yarn tsc -b tsconfig.project-references.json -v -
Delete the file 'packages/bar/src/clean.ts'. This file is consumed by 'packages/foo/src/index2.ts'. Note that we have paths defined for 'bar/clean' in 'tsconfig.json':
rm packages/bar/src/clean.ts -
Run TypeScript build with project references again. This should update the 'tsDist' folder at the repo root with emitted declarations. However, it doesn't throw any error, even though 'packages/foo/src/index2.ts' is consuming a non-existent file:
yarn tsc -b tsconfig.project-references.json -v
Repository for reproduction - https://github.com/sudesh-atlassian/project-references-debug-1.git
Tested with typescript version - v5.4.2, v5.5.2 and v5.6.2
Queries
- Is this expected behaviour, where typecheck would not typecheck when we have a cache and a file is deleted
- Is there a known way to mitigate this issue
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem verlinkten Reproduktionsrepository und untersuche tsconfig.project-references.json, die Basis-tsconfig und das bar/foo-Projektsetup. Führe yarn tsc -b tsconfig.project-references.json -v aus, lösche packages/bar/src/clean.ts und führe den Build erneut aus. Als erledigt gilt die Feststellung und Dokumentation, ob der zweite Build die fehlende per Pfad importierte Datei melden sollte, mit einer Abdeckung des beobachteten Verhaltens, falls angemessen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- build-system, compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100