TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

Use explicit extensions for imports within src

Open jakebailey opened this issue 1 year ago • 3 comments

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"?

jakebailey avatar May 02 '24 23:05 jakebailey

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 @sheetalkamat, @mjbvz, @zkat, and @joj for you. Feel free to loop in other consumers/maintainers if necessary.

typescript-bot avatar May 02 '24 23:05 typescript-bot

Something weird with the unused baselines check?

andrewbranch avatar May 03 '24 00:05 andrewbranch

Weird, will take a look later.

jakebailey avatar May 03 '24 00:05 jakebailey

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

jakebailey avatar May 03 '24 02:05 jakebailey

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

andrewbranch avatar May 03 '24 16:05 andrewbranch

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

jakebailey avatar May 03 '24 16:05 jakebailey

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

andrewbranch avatar May 03 '24 16:05 andrewbranch

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 avatar May 06 '24 22:05 jakebailey