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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce extensions on TypeScript files as well #639

Merged
merged 2 commits into from Nov 26, 2021

Conversation

fregante
Copy link
Member

@fregante fregante commented Nov 25, 2021

I think this config should be dropped. Reasons:

  • it actually "breaks" the rule for .ts/tsx files because it allows them to be imported without extension

    1. create file.ts
    2. import './file' in another.ts
    3. No errors! 馃槹
  • it duplicates TypeScript鈥檚 own error, but with a worse message:

    Screen Shot 3

@fregante
Copy link
Member Author

fregante commented Nov 25, 2021

The side effect of this change is that the rule will now suggest to use .ts extension in that case

  2:27  error  Missing file extension "ts" for "./sender"  import/extensions

but once you add it, TypeScript will ask you to change it to .js, which is fine and is really TypeScript鈥檚 limit and rule here.

error TS2691: An import path cannot end with a '.ts' extension. Consider importing './sender.js' instead.

@fregante fregante changed the title Drop ts/tsx mentions from import/extensions config Enforce extensions on TypeScript files as well Nov 25, 2021
@sindresorhus sindresorhus merged commit 0e90967 into xojs:main Nov 26, 2021
@fregante fregante deleted the patch-1 branch November 26, 2021 08:39
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 this pull request may close these issues.

None yet

2 participants