ts-api-utils icon indicating copy to clipboard operation
ts-api-utils copied to clipboard

refactor: use namespace import to import "typescript"

Open fisker opened this issue 1 year ago • 5 comments

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.

fisker avatar Nov 25 '24 15:11 fisker

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 77.08%. Comparing base (39e06e3) to head (ea9702c). Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #588   +/-   ##
=======================================
  Coverage   77.08%   77.08%           
=======================================
  Files          50       50           
  Lines        5009     5009           
  Branches      688      688           
=======================================
  Hits         3861     3861           
  Misses       1147     1147           
  Partials        1        1           
Flag Coverage Δ
4.8.4 74.44% <100.00%> (ø)
latest 76.66% <100.00%> (ø)

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: 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.

codecov[bot] avatar Nov 25 '24 16:11 codecov[bot]

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

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

fisker avatar Nov 25 '24 16:11 fisker

Looks like typescript support namespace import now.

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

fisker avatar Mar 19 '25 05:03 fisker

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

RebeccaStevens avatar Mar 19 '25 08:03 RebeccaStevens

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

JoshuaKGoldberg avatar Mar 19 '25 13:03 JoshuaKGoldberg