Skip to content

refactor: use namespace import to import "typescript"#588

Merged
RebeccaStevens merged 5 commits into
JoshuaKGoldberg:v3from
fisker:typescript-namespace-import
Feb 24, 2026
Merged

refactor: use namespace import to import "typescript"#588
RebeccaStevens merged 5 commits into
JoshuaKGoldberg:v3from
fisker:typescript-namespace-import

Conversation

@fisker

@fisker fisker commented Nov 25, 2024

Copy link
Copy Markdown
Contributor

PR Checklist

Overview

In build script of Prettier, we transform the typescript package to ESM for better tree-shake, then we rewrite "import"s
from ts-api-utils
, do you think it's acceptable to use namespace import here? so we don't need rewrite these "import"s.

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with this, but:

  • Would want to hear from @RebeccaStevens as they've been doing a bunch of fantastic work improving the build system (as you've seen)
  • If this is 👍, there should be a lint rule to stop new default imports from being added in the future

@JoshuaKGoldberg JoshuaKGoldberg added the status: waiting for author Needs an action taken by the original poster label Nov 25, 2024
@codecov

codecov Bot commented Nov 25, 2024

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.16%. Comparing base (aaa62da) to head (9eedda3).
⚠️ Report is 1 commits behind head on v3.

Additional details and impacted files
@@           Coverage Diff           @@
##               v3     #588   +/-   ##
=======================================
  Coverage   61.16%   61.16%           
=======================================
  Files          35       35           
  Lines        2987     2987           
  Branches      468      468           
=======================================
  Hits         1827     1827           
  Misses       1160     1160           
Flag Coverage Δ
5.5.4 61.16% <100.00%> (ø)
latest 61.16% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fisker

fisker commented Nov 25, 2024

Copy link
Copy Markdown
Contributor Author

Looks like it's a bad idea, the original package can't be namespace imported

> Object.keys(await import('typescript'))
[ 'default' ]

@fisker fisker closed this Nov 25, 2024
@fisker fisker deleted the typescript-namespace-import branch November 25, 2024 16:21
@fisker fisker restored the typescript-namespace-import branch March 19, 2025 05:33
@fisker

fisker commented Mar 19, 2025

Copy link
Copy Markdown
Contributor Author

Looks like typescript support namespace import now.

> Object.keys(await import('typescript')).length
2238

@fisker fisker reopened this Mar 19, 2025
@fisker fisker force-pushed the typescript-namespace-import branch from 865c19b to ea9702c Compare March 19, 2025 05:41
@RebeccaStevens

Copy link
Copy Markdown
Collaborator

Seems good to me. We just need to check that this is valid in all our supported versions of TypeScript

@JoshuaKGoldberg

Copy link
Copy Markdown
Owner

Filed #711 -> #712 on the versioning question. Agreed, I think we're blocked for now? ☹️

@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as draft March 19, 2025 13:15
@RebeccaStevens RebeccaStevens added status: blocked Waiting for something else to be resolved 🙅 and removed status: waiting for author Needs an action taken by the original poster labels Mar 20, 2025
@RebeccaStevens RebeccaStevens changed the base branch from main to v3 February 24, 2026 06:51
@RebeccaStevens RebeccaStevens marked this pull request as ready for review February 24, 2026 06:54
@RebeccaStevens RebeccaStevens merged commit 7191948 into JoshuaKGoldberg:v3 Feb 24, 2026
20 checks passed
@fisker fisker deleted the typescript-namespace-import branch February 24, 2026 14:36
RebeccaStevens added a commit that referenced this pull request Mar 1, 2026
Co-authored-by: Rebecca Stevens <rebecca.stevens@outlook.co.nz>
fixes #711
RebeccaStevens added a commit that referenced this pull request Mar 1, 2026
Co-authored-by: Rebecca Stevens <rebecca.stevens@outlook.co.nz>
fixes #711
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: blocked Waiting for something else to be resolved 🙅

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🚀 Feature: Use namespace import from typescript, not default import

3 participants