question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeScript 4.7 source map file extension mismatch

See original GitHub issue

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

image

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

image

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
arendjrcommented, Jun 2, 2022

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.

0reactions
unionalcommented, Jul 27, 2022

I’m not clear on what you are saying is broken here

Please follow the steps and description above:

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

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - Module Resolution - TypeScript
Module resolution is the process the compiler uses to figure out what an import refers to. Consider an import statement like import {...
Read more >
TypeScript source map files don't work with Chrome
1 and have source maps working correctly in Chrome. My source map begins {"version":3,"file":"pe.plugins.js","sources":[" ...
Read more >
Firebase JavaScript SDK Release Notes - Google
Added types fields to exports object in package.json files for all published packages to make them compatible with TypeScript 4.7 support of Node.js...
Read more >
Build with ES modules | ArcGIS Maps SDK for JavaScript 4.25
To resolve the mismatch and avoid any unexpected issues or errors with API functionality, be sure to recopy the assets from the current...
Read more >
Changelog - Cypress Documentation
Fixes #24652; Fixed TypeScript types for testIsolation . ... Now, in the terminal, users will see the source map line and column number...
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