microsoft / microsoft/TypeScript

TypeScript skips type-checking despite deleted file in referenced project

Open
#60,335 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Domain: tsc -b
Dominant language
Go
Stars
111k
Forks
14.4k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

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

  1. 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

  2. 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

  3. 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked reproduction repository and inspect tsconfig.project-references.json, the base tsconfig, and the bar/foo project setup. Run yarn tsc -b tsconfig.project-references.json -v, delete packages/bar/src/clean.ts, and run the build again. Done means determining and documenting whether the second build should report the missing path-imported file, with coverage for the observed behavior if appropriate.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system, compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.