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

'.ts' is not a valid suffix for a module - Consider renaming the repo. #9

Closed
rrichardson opened this issue Jul 27, 2022 · 4 comments
Closed

Comments

@rrichardson
Copy link

When using oxide.ts in the latest (anything after 4.2) typescript, I get this error:

index.d.ts:3:53 - error TS2691: An import path cannot end with a '.ts' extension. Consider importing 'oxide.js' instead.

3 import { Option, Some, None, Result, Ok, Err } from "oxide.ts";
                                                       ~~~~~~~~~~                     

IMO it's a bug in tsc, because I'm not trying to import a local file, but a module instead, which should be obvious from the lack of local path separator.

There are a bunch of people complaining about this, also Deno requires file extensions, instead of banning them. I think this restriction will be lifted, but either way, to avoid current and future errors, would you consider renaming oxide.ts to oxide-ts?

see:
microsoft/TypeScript#38149
microsoft/TypeScript#37582
microsoft/TypeScript#44839

@traverse1984
Copy link
Owner

Yeah - that seems pretty annoying. Changing the name makes sense.

@traverse1984
Copy link
Owner

Buggered it up a bit - but slight issue is that it's not going to be possible to rename to oxide-ts due to being too similar to the original package name. Thoughts?

@andrewbranch
Copy link

This error only gets reported when the import failed to resolve to anything—expected if, e.g., someone had written this before running npm install. If you’re getting it in a project that’s fully set up, it means the package isn’t resolving correctly and renaming it will only trade this error for the standard Cannot find module '{0}' or its corresponding type declarations error. You can run tsc --traceResolution to get a log of where the compiler looked to try to find typings. I wonder if this is a problem: https://github.com/traverse1984/oxide-ts/blob/4a3ff234ba9928fa151a998f7ad5d7f359c31be2/package.json#L6

We usually see this pointing to a file, not a directory relying on index-file resolution. I would have thought that index-file resolution does work here, but I can’t remember for sure off the top of my head. Anyway, --traceResolution will tell you. Point is, this is not a bug in tsc and the package does not need to be renamed to fix it. There are other npm packages whose name ends in .ts that work fine too.

@traverse1984
Copy link
Owner

Thanks so much for your reply Andrew, clearly I'd misunderstood the problem. @rrichardson Does this resolve your issue?

@traverse1984 traverse1984 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 6, 2022
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

3 participants