Skip to content

Use explicit extensions for imports within src - #58421

Merged
Jake Bailey (jakebailey) merged 13 commits into
microsoft:mainfrom
jakebailey:js-extensions
May 7, 2024
Merged

Use explicit extensions for imports within src#58421
Jake Bailey (jakebailey) merged 13 commits into
microsoft:mainfrom
jakebailey:js-extensions

Conversation

@jakebailey

@jakebaileyJake Bailey (jakebailey) commented May 2, 2024

Copy link
Copy Markdown
Member

This is extracted from #58419.

Doing this now would reduce churn, but I'm not 100% certain how we can avoid adding the "wrong" kind of imports in the future before "type": "module"? Lint rule!

@typescript-bot

Copy link
Copy Markdown
Contributor

Thanks for the PR! It looks like you've changed the TSServer protocol in some way. Please ensure that any changes here don't break consumers of the current TSServer API. For some extra review, we'll ping Sheetal Nandi (@sheetalkamat), Matt Bierner (@mjbvz), Kat Marchán (@zkat), and Joaquin Jares (@joj) for you. Feel free to loop in other consumers/maintainers if necessary.

@andrewbranch

Copy link
Copy Markdown
Member

Something weird with the unused baselines check?

@jakebailey

Copy link
Copy Markdown
MemberAuthor

Weird, will take a look later.

@jakebailey

Copy link
Copy Markdown
MemberAuthor

Andrew Branch (@andrewbranch) Is there a way to force this to always be required, even though we're currently being treated as CommonJS?

@andrewbranch

Copy link
Copy Markdown
Member

Not in tsc. You can set "importModuleSpecifierEnding": "js" in VS Code preferences for auto imports, and otherwise use a lint rule to enforce.

@jakebailey

Copy link
Copy Markdown
MemberAuthor

I'll whip up a lint rule and set that, thanks!

@andrewbranch

Copy link
Copy Markdown
Member

I know eslint-plugin-import has a rule for that; not sure about others.

Comment threadscripts/eslint/rules/js-extensions.cjs
@jakebailey

Copy link
Copy Markdown
MemberAuthor

Sanity checked, and reverting all changes in src, running hereby lint --fix and dprint nets the right result, missing only the manual changes for using export * for the unit test reexport file (no runtime difference, but it makes the imports checked), and then two unit test loading hacks that are in place due to our goofy test runner.

@jakebailey
Jake Bailey (jakebailey) merged commit 16beff1 into microsoft:mainMay 7, 2024
@jakebailey
Jake Bailey (jakebailey) deleted the js-extensions branch June 17, 2024 21:06
@microsoftMicrosoft (microsoft) locked as resolved and limited conversation to collaborators Oct 16, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Author: TeamFor Uncommitted BugPR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@jakebailey@typescript-bot@andrewbranch