Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make .js paths lookup for .ts as a 2nd fallback #21

Open
izelnakri opened this issue Jun 27, 2022 · 0 comments
Open

Make .js paths lookup for .ts as a 2nd fallback #21

izelnakri opened this issue Jun 27, 2022 · 0 comments

Comments

@izelnakri
Copy link

izelnakri commented Jun 27, 2022

Currently doesnt work on typescript projects that has the relative files referenced as with ".js". This behavior must be included in this package. Example:

import Changeset from "./changeset.js"; // clicking on gf should go to ./changeset.ts
import RevisionHistory from "./revision-history.ts";
import Serializer, { transformValue } from "./serializer.js";

console.log(Changeset, RevisionHistory, Serializer, transformValue);

This is actually an unfortunate best practice decided by the typescript team, they are on purpose not changing typescript compiler behavior for years and advocate for the use of .js extensions for projects that build/transpile for node.js ESM imports. In order to build a typescript file that typechecks, transpiles correctly to ES module it is expected to be referenced as "./module.js" even if the file is actually a "./module.ts".

Related references:
microsoft/TypeScript#16577 (comment) <- The relevant github issue
https://stackoverflow.com/questions/62619058/appending-js-extension-on-relative-import-statements-during-typescript-compilat/62626938#62626938

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant