-
-
Notifications
You must be signed in to change notification settings - Fork 11
Description
Bug Report Checklist
- I have pulled the latest
main
branch of the repository. - I have searched for related issues and found none that matched my issue.
Overview
Coming over from #588: there's interest in switching from default-importing TypeScript to namespace-importing:
- import ts from "typescript";
+ import * as ts from "typescript";
Prettier's https://github.com/prettier/prettier/blob/96d2fe439dcf784806d6543c422fe6ffe679ca4c/scripts/build/config.js#L278 is an example of downstream consumers that have to do work to manually edit files. They do so because tree shaking works better for namespace imports apparently.
Speaking of which, @fisker I have a vague memory of seeing an explanation but now can't find it. Why does a default import not work well for tree-shaking? Are there tracking issues for tools to support it?
Additional Info
TypeScript only added support for a named import in https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-5.html#easier-api-consumption-from-ecmascript-modules. I think this is blocked on ts-api-utils
no longer supporting earlier TypeScript versions.
💖