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

TypeScript complains about file extensions in import statements #71

Closed
marvinhagemeister opened this issue Jul 21, 2020 · 5 comments
Closed

Comments

@marvinhagemeister
Copy link
Member

marvinhagemeister commented Jul 21, 2020

Currently TypeScript complains about adding an .ts, .tsx, .js or .jsx extension to the import path.

Screenshot from 2020-07-21 09-07-23

Not sure what we can do on our end here.

Relevant TS issues:

@developit
Copy link
Member

Yeah, I'm at a bit of a loss here too :(

One option would be to allow extension-less imports, but that kinda breaks the "it's just modules" philosophy just to make TS happy.

@marvinhagemeister
Copy link
Member Author

marvinhagemeister commented Jul 21, 2020

Just noticed: By default vscode will insert auto-imports for every function/value/class you use from another file and those are always without an extension.

EDIT: And having extensions in the file paths breaks cmd/control click to jump to the function definition

@developit
Copy link
Member

@marvinhagemeister I'm not sure if its my config, but for me the imports are inserted with a file extension - but only if any current imports already have the extension.

@marvinhagemeister
Copy link
Member Author

@developit Very strange, just to confirm: Does this happen inside a TS file with a .ts/.tsx import? Importing JS files with an extension is perfectly valid TS. They only have that weird exception for .ts/.tsx files.

@developit
Copy link
Member

developit commented Sep 30, 2020

I think now you can choose to use .js extensions or no extensions for TS files, so this one can be closed out now (lmk if I've missed something).

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

Successfully merging a pull request may close this issue.

2 participants