TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

TypeScript skips type-checking despite deleted file in referenced project

Open sudesh-atlassian opened this issue 1 year ago • 1 comments

Acknowledgement

  • [x] 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

sudesh-atlassian avatar Oct 24 '24 03:10 sudesh-atlassian

We were affected by this bug as well, and I unintentionally made a similar repro repo before coming across this issue: https://github.com/AllySummers/typescript-cache-bug

AllySummers avatar Jun 18 '25 13:06 AllySummers