TS6305: Output file '/path/to/dist/index.d.ts' has not been built from source file '/path/to/src/index.ts'.

See original GitHub issue

Current behavior

You receive a TS6305 error when using the fork-ts-checker-webpack-plugin. The error does not show up when not using the plugin. Running the build again without running a cleanup script to remove the output directory and buildinfo file will result in a no error being outputted. See the steps to reproduce for more info.

Expected behavior

You either receive this error consistently when using or not using the plugin, or don’t receive the error at all.

Steps to reproduce the issue

https://github.com/mvargeson/fork-ts-checker-webpack-plugin-resolution-issue#how-to-reproduce

Issue reproduction repository

https://github.com/mvargeson/fork-ts-checker-webpack-plugin-resolution-issue

Environment

  • fork-ts-checker-webpack-plugin: 4.0.4
  • typescript: 3.8.2
  • tslint: N/A
  • webpack: 4.41.5
  • os: macOS 10.15.3
  • node: 12.16.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
berickson1commented, Feb 28, 2020

I did a little bit of digging into this and I think it’s a race condition when building.

I believe this stems from fork-ts-checker and ts-loader running in parallel. Typescript composite projects rely on the dist files being emitted and on disk, so if fork-ts-checker starts typechecking a module that ts-loader hasn’t emitted yet, the above error would likely occur. That also explains why running build a second time resolves the issue (since the older files are already on disk). This could potentially result in changes not being type-checked if on-disk files were stale.

I don’t have any concrete evidence to back this up but I think it’s plausible…

1reaction
aferditakrasniqicommented, Mar 11, 2022

@piotr-oles I am having this issue with version “fork-ts-checker-webpack-plugin”: “7.2.1”. I have a monorepo with yarn workspaces > services using a shared library as a dependency, imports from the library fail with this TS6305:… error. It works fine when building locally with tsc -b.

For context on webpack config we’re using babel-loader as well as ts-loader (ts-loader has these options projectReferences: true, transpileOnly: true)

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript project with references - Stack Overflow
Found this when searching for "typescript references has not been built from source file". My mistake was that I was running tsc -p ......
Read more >
Documentation - Project References - TypeScript
Project references are a new feature in TypeScript 3.0 that allow you to structure your TypeScript programs into smaller pieces.
Read more >
Typescript outDir ignored in monorepo : WEB-44572
ts ' has not been built from source file 'E:/downloads/project-references-demo/core/utilities.ts'. reported when compiling. No files are generated for me in core ...
Read more >
You might not need TypeScript project references - Turborepo
If the referenced project produces an outFile , the output file .d.ts file's declarations will be visible in this project; Running build mode...
Read more >
Breaking down TypeScript project references | by Jake Ginnivan
Once built, projects reference the built artifacts (the .js + .d.ts files) rather than the source (ie, /dist, not /src).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found