Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal: upgrade to TypeScript ^5.7.0 #1894

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open

Conversation

williaster
Copy link
Collaborator

@williaster williaster commented Dec 19, 2024

🏠 Internal

Working toward react@19 (#1883), this PR

  • Updates jest / related dependencies, basically pulling in changes from Upgrade jest #1892
    • react@19 uses queueMicrotask which is not supported by our 5 year old version of jest
  • Updates TypeScript from 3.8 to 5.7 because upgrading jest dependencies couldn't compile
  • Updates eslint + @typescript-eslint/eslint-plugin so we can use @typescript-eslint/consistent-type-imports to auto fix import type { FooType } from './foo'; required in TypeScript@^5.4
  • Updates several other dependencies to fix misc type issues
  • updates from node >= 16.13.0 to node >= 18.8.0
  • removes @visx/xychart's withRegisteredData HOC because the compiled types were so complex they became invalid (similar to [regression - 5.4] Generated .d.ts file contains invalid types microsoft/TypeScript#57843)

@williaster williaster mentioned this pull request Dec 19, 2024
@williaster williaster changed the title internal: upgrade to TypeScript ^4.8 internal: upgrade to TypeScript ^5.7.0 Dec 20, 2024
@@ -80,6 +80,7 @@ module.exports = {
'error',
{ assertionStyle: 'as', objectLiteralTypeAssertions: 'allow-as-parameter' },
],
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],
Copy link
Collaborator Author

@williaster williaster Dec 20, 2024

Choose a reason for hiding this comment

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

enabled auto-fixing import { FooType } from './foo' to import type { FooType } from './foo' which TS now cares about

Copy link
Contributor

Choose a reason for hiding this comment

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

Typescript should not require this afaik unless verbatimModuleSyntax is enabled 🤔

But it's a good practice anyway, so 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think I was getting *.d.ts is not a module errors, but actually fixed that in tsconfig with "moduleResolution": "node16"

but agree this is best practice/we should do it anyway 👍

@@ -6,7 +6,7 @@
"scripts": {
"build": "next build && next export",
"deploy": "rm -rf out && yarn build && cd out && touch .nojekyll && git init && git add . && git commit -m \"Deploy commit\" && git remote add origin [email protected]:airbnb/visx.git && git push -f origin master:gh-pages",
"dev": "next",
"dev": "NODE_OPTIONS=--openssl-legacy-provider next",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

may need to update next, minimally need to add this same option to the build. don't fully understand why there is an error without this, because our version of next should be using webpack 5 by default 🤔

Copy link
Contributor

@darthmaim darthmaim Dec 20, 2024

Choose a reason for hiding this comment

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

I've tried to upgrade next to the latest version using npx @next/codemod upgrade back when I made #1889 in an attempt to verify all components with react 19, but when I tried react-docgen-typescript-loader did not work anymore (everything else did though), so I didn't continue working on it.

I can try again in the next few days based on this branch, maybe some other dependency upgrade made it work in the meantime, or maybe there is an easy replacement for that dependency...

Comment on lines +10 to +11
import type { OrientationType } from '../constants/orientation';
import Orientation from '../constants/orientation';
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI, instead of splitting those lines up you can also do this:

Suggested change
import type { OrientationType } from '../constants/orientation';
import Orientation from '../constants/orientation';
import Orientation, { type OrientationType } from '../constants/orientation';

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

had just used the eslint autofix here. this doesn't seem to be configurable https://typescript-eslint.io/rules/consistent-type-imports/. no strong opinion from me.

@williaster williaster marked this pull request as ready for review December 20, 2024 19:09
Copy link

Size Changes

Package Diff ESM Prev ESM CJS Prev CJS
visx-bounds +0.0% 2.6 KB 2.6 KB 3.06 KB 3.06 KB
visx-brush +0.4% 54.39 KB 54.19 KB 58.56 KB 58.36 KB
visx-scale +0.1% 18.45 KB 18.43 KB 29.22 KB 29.2 KB
visx-shape +0.0% 79.87 KB 79.85 KB 100.19 KB 100.17 KB
visx-text +0.3% 8.1 KB 8.08 KB 9.56 KB 9.54 KB
visx-xychart +0.8% 170.73 KB 169.38 KB 220.63 KB 220.2 KB

Compared to master. File sizes are unminified and ungzipped.

View raw build stats

Previous (master)

{
  "visx-annotation": {
    "esm": 30333,
    "lib": 40419
  },
  "visx-axis": {
    "esm": 20709,
    "lib": 25153
  },
  "visx-bounds": {
    "esm": 2661,
    "lib": 3136
  },
  "visx-brush": {
    "esm": 55492,
    "lib": 59763
  },
  "visx-chord": {
    "esm": 3301,
    "lib": 4484
  },
  "visx-clip-path": {
    "esm": 3993,
    "lib": 5491
  },
  "visx-curve": {
    "esm": 323,
    "lib": 1462
  },
  "visx-delaunay": {
    "esm": 2422,
    "lib": 3231
  },
  "visx-demo": {
    "esm": 0,
    "lib": 36814
  },
  "visx-drag": {
    "esm": 12570,
    "lib": 14176
  },
  "visx-event": {
    "esm": 3815,
    "lib": 5091
  },
  "visx-geo": {
    "esm": 12930,
    "lib": 16196
  },
  "visx-glyph": {
    "esm": 13761,
    "lib": 18476
  },
  "visx-gradient": {
    "esm": 16078,
    "lib": 20593
  },
  "visx-grid": {
    "esm": 18097,
    "lib": 21710
  },
  "visx-group": {
    "esm": 1471,
    "lib": 2070
  },
  "visx-heatmap": {
    "esm": 7040,
    "lib": 8347
  },
  "visx-hierarchy": {
    "esm": 12093,
    "lib": 17820
  },
  "visx-legend": {
    "esm": 25546,
    "lib": 32474
  },
  "visx-marker": {
    "esm": 8204,
    "lib": 10332
  },
  "visx-mock-data": {
    "esm": 326036,
    "lib": 329336
  },
  "visx-network": {
    "esm": 4497,
    "lib": 6572
  },
  "visx-pattern": {
    "esm": 11689,
    "lib": 15673
  },
  "visx-point": {
    "esm": 1003,
    "lib": 1781
  },
  "visx-react-spring": {
    "esm": 13253,
    "lib": 16586
  },
  "visx-responsive": {
    "esm": 15936,
    "lib": 18296
  },
  "visx-sankey": {
    "esm": 3543,
    "lib": 4594
  },
  "visx-scale": {
    "esm": 18870,
    "lib": 29896
  },
  "visx-shape": {
    "esm": 81766,
    "lib": 102573
  },
  "visx-stats": {
    "esm": 13498,
    "lib": 15050
  },
  "visx-text": {
    "esm": 8276,
    "lib": 9773
  },
  "visx-threshold": {
    "esm": 2844,
    "lib": 3723
  },
  "visx-tooltip": {
    "esm": 14383,
    "lib": 19715
  },
  "visx-vendor": {
    "esm": 2492,
    "lib": 2702
  },
  "visx-visx": {
    "esm": 1524,
    "lib": 4155
  },
  "visx-voronoi": {
    "esm": 2137,
    "lib": 2824
  },
  "visx-wordcloud": {
    "esm": 2506,
    "lib": 3311
  },
  "visx-xychart": {
    "esm": 173440,
    "lib": 225481
  },
  "visx-zoom": {
    "esm": 16176,
    "lib": 18872
  }
}

Current

{
  "visx-annotation": {
    "esm": 30333,
    "lib": 40419
  },
  "visx-axis": {
    "esm": 20709,
    "lib": 25153
  },
  "visx-bounds": {
    "esm": 2662,
    "lib": 3136
  },
  "visx-brush": {
    "esm": 55698,
    "lib": 59969
  },
  "visx-chord": {
    "esm": 3301,
    "lib": 4484
  },
  "visx-clip-path": {
    "esm": 3993,
    "lib": 5491
  },
  "visx-curve": {
    "esm": 323,
    "lib": 1462
  },
  "visx-delaunay": {
    "esm": 2422,
    "lib": 3231
  },
  "visx-demo": {
    "esm": 0,
    "lib": 0
  },
  "visx-drag": {
    "esm": 12570,
    "lib": 14176
  },
  "visx-event": {
    "esm": 3815,
    "lib": 5091
  },
  "visx-geo": {
    "esm": 12930,
    "lib": 16196
  },
  "visx-glyph": {
    "esm": 13761,
    "lib": 18476
  },
  "visx-gradient": {
    "esm": 16078,
    "lib": 20593
  },
  "visx-grid": {
    "esm": 18097,
    "lib": 21710
  },
  "visx-group": {
    "esm": 1471,
    "lib": 2070
  },
  "visx-heatmap": {
    "esm": 7040,
    "lib": 8347
  },
  "visx-hierarchy": {
    "esm": 12093,
    "lib": 17820
  },
  "visx-legend": {
    "esm": 25546,
    "lib": 32474
  },
  "visx-marker": {
    "esm": 8204,
    "lib": 10332
  },
  "visx-mock-data": {
    "esm": 326036,
    "lib": 329336
  },
  "visx-network": {
    "esm": 4497,
    "lib": 6572
  },
  "visx-pattern": {
    "esm": 11689,
    "lib": 15673
  },
  "visx-point": {
    "esm": 1003,
    "lib": 1781
  },
  "visx-react-spring": {
    "esm": 13253,
    "lib": 16586
  },
  "visx-responsive": {
    "esm": 15936,
    "lib": 18296
  },
  "visx-sankey": {
    "esm": 3543,
    "lib": 4594
  },
  "visx-scale": {
    "esm": 18891,
    "lib": 29917
  },
  "visx-shape": {
    "esm": 81787,
    "lib": 102594
  },
  "visx-stats": {
    "esm": 13498,
    "lib": 15050
  },
  "visx-text": {
    "esm": 8297,
    "lib": 9794
  },
  "visx-threshold": {
    "esm": 2844,
    "lib": 3723
  },
  "visx-tooltip": {
    "esm": 14383,
    "lib": 19715
  },
  "visx-vendor": {
    "esm": 2492,
    "lib": 2702
  },
  "visx-visx": {
    "esm": 1524,
    "lib": 4155
  },
  "visx-voronoi": {
    "esm": 2137,
    "lib": 2824
  },
  "visx-wordcloud": {
    "esm": 2506,
    "lib": 3324
  },
  "visx-xychart": {
    "esm": 174826,
    "lib": 225920
  },
  "visx-zoom": {
    "esm": 16176,
    "lib": 18872
  }
}

@williaster
Copy link
Collaborator Author

everything is good except the typescript -> docs is broken. may not land this until after the holidays.

@darthmaim
Copy link
Contributor

everything is good except the typescript -> docs is broken. may not land this until after the holidays.

I briefly tried to look into fixing the docs and wrote everything down in #1897.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError: (0 , _web.useTransition) is not a function
2 participants