microsoft / microsoft/TypeScript
TypeScript skips type-checking despite deleted file in referenced project
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされた再現リポジトリから始めて、tsconfig.project-references.json、ベースの tsconfig、bar/foo プロジェクトのセットアップを調査します。yarn tsc -b tsconfig.project-references.json -v を実行し、packages/bar/src/clean.ts を削除して、もう一度ビルドを実行します。完了条件は、2 回目のビルドでパス経由で import された欠落ファイルが報告されるべきかどうかを判断して文書化し、適切であれば観測された動作のカバレッジを含めることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- build-system, compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100