TypeScript 4.7 source map file extension mismatch
See original GitHub issueBug Report
🔎 Search Terms
source map, extension
🕗 Version & Regression Information
TypeScript 4.7.2
⏯ Playground Link
Not a Playground link, but the repro is here: https://github.com/unional/tersify/tree/webpack
To repro it, run yarn bundle
and open the demo.html
in browser.
You can see that the source-map-loader
able to get the unpartial/ts/index.ts
file, but not the files it referenced (./required.js
, ./unpartial.js
).
This is because the files are actually in TS. i.e. required.ts
and unpartial.ts
.
I’m not sure if this is a TypeScript 4.7 bug or source-map-loader
needs to be updated to support this.
But given it was working prior to TypeScript 4.7 and JS in general,
it is likely that the sourcemap generated by TypeScript 4.7 needs some adjustments.
💻 Code
The referenced code unpartial
is here: https://github.com/unional/unpartial
It is build with sourceMap: true
in tsconfig.json
Since this is related to how the code is build and consumed, I don’t have a minimal repro for this. But the library I chose to demo this are simple enough that should be simple enough.
🙁 Actual behavior
Unable to consume the source map generated by TypeScript library using TS 4.7
🙂 Expected behavior
Should work, as shown in this branch: https://github.com/unional/tersify/tree/webpack-old
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:5 (4 by maintainers)
Top GitHub Comments
This seems to be another unintended consequence of the fact that TypeScript does not rewrite extensions to source files for you. #49083 is asking for a change in this behavior.
Please follow the steps and description above:
The bottom line is, the source-map generated by TypeScript works in one way, does not in another. TypeScript transpile code to JavaScript. and that’s we get distributed, along with its source map.
When consuming a package, written in TypeScript or not, the source map should work. The fact that it was written in TypeScript should be out of the picture.