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

chore: upgrade to TS 4.7, compile with NodeNext #7586

Merged
merged 7 commits into from Jun 15, 2022
Merged

chore: upgrade to TS 4.7, compile with NodeNext #7586

merged 7 commits into from Jun 15, 2022

Conversation

Josh-Cena
Copy link
Collaborator

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

This is still a pain in the ass, but at least better than nothing.

I had to add ambient declarations for a few packages (namely, eta and webpackbar) that have incompatible package.json manifest formats. I hope they can be fixed soon.

I also corrected the format of our own manifests to make sure they can be consumed by external projects compiled with NodeNext. I'm already having pain with this in my own projects.

This can be a step towards #6520.

Test Plan

Test links

Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/

Related issues/PRs

@Josh-Cena Josh-Cena added the pr: maintenance This PR does not produce any behavior differences to end users when upgrading. label Jun 9, 2022
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jun 9, 2022
@netlify
Copy link

netlify bot commented Jun 9, 2022

[V2]

Name Link
🔨 Latest commit 4e817b0
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/62aa10dc98b447547b084097
😎 Deploy Preview https://deploy-preview-7586--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions
Copy link

github-actions bot commented Jun 9, 2022

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 87 🟢 100 🟢 100 🟢 100 🟢 90 Report
/docs/installation 🟠 83 🟢 100 🟢 100 🟢 100 🟢 90 Report

@github-actions
Copy link

github-actions bot commented Jun 9, 2022

Size Change: +10 B (0%)

Total Size: 801 kB

ℹ️ View Unchanged
Filename Size Change
website/.docusaurus/globalData.json 52.6 kB 0 B
website/build/assets/css/styles.********.css 106 kB 0 B
website/build/assets/js/main.********.js 603 kB +10 B (0%)
website/build/index.html 38.9 kB 0 B

compressed-size-action

@Josh-Cena
Copy link
Collaborator Author

Holding off till new version of vfile is released with better type declaration

@Josh-Cena Josh-Cena force-pushed the jc/ts-4.7 branch 2 times, most recently from a1bf90c to dc9963c Compare June 11, 2022 12:41
Comment on lines 128 to 131
type RawProps = ComponentProps<typeof ${componentName}Type>;
// ComponentProps is a little buggy, quick fix.
// https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/60766
type Props = unknown extends RawProps ? {} : RawProps;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ideally revert before merge—depends on if DT is open to fixing this.

Copy link
Collaborator

@slorber slorber Jun 15, 2022

Choose a reason for hiding this comment

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

cf Discord

We'd rather export our own ComponentProps or WrapperProps type instead of inlining these more complex types

and let's track DefinitelyTyped/DefinitelyTyped#60766, but not sure there will be a fix so soon

@Josh-Cena Josh-Cena force-pushed the jc/ts-4.7 branch 2 times, most recently from f826fa7 to 3691d0e Compare June 11, 2022 15:28
Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

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

Great 👍 almost LGTM

packages/docusaurus/src/deps.d.ts Show resolved Hide resolved
Comment on lines 43 to 88
export const useDocsData = (pluginId: string | undefined): GlobalPluginData =>
export const useDocsData = (pluginId?: string): GlobalPluginData =>
Copy link
Collaborator

Choose a reason for hiding this comment

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

using | undefined is done on purpose to prevent useDocsData() calls: if the pluginId does not matter in a given context, user should be explicit and use useDocsData(undefined)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The types exposed in the declaration that I just removed had pluginId?: string though 😄 Should I correct this here? I also feel like it's largely unsafe, but if you are not using multi-instance, omitting the ID is very convenient.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd rather keep this | undefined for now, just for us, considering those client APIs are not documented

Comment on lines 128 to 131
type RawProps = ComponentProps<typeof ${componentName}Type>;
// ComponentProps is a little buggy, quick fix.
// https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/60766
type Props = unknown extends RawProps ? {} : RawProps;
Copy link
Collaborator

@slorber slorber Jun 15, 2022

Choose a reason for hiding this comment

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

cf Discord

We'd rather export our own ComponentProps or WrapperProps type instead of inlining these more complex types

and let's track DefinitelyTyped/DefinitelyTyped#60766, but not sure there will be a fix so soon

Comment on lines +10 to 11
// @ts-expect-error: TODO, we need to make theme-classic have type: module
import copy from 'copy-text-to-clipboard';
Copy link
Collaborator Author

@Josh-Cena Josh-Cena Jun 15, 2022

Choose a reason for hiding this comment

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

This is specifically because Webpack resolution is neither node nor NodeNext. Webpack allows exports, importing ESM in CJS, importing CJS in ESM, using both require and import in one file, importing .ts extension, importing .js extension... everything.

https://twitter.com/atcb/status/1536831060960419841
https://gist.github.com/andrewbranch/3020c4e24092bd37f7e210d6f050ef26

@slorber
Copy link
Collaborator

slorber commented Jun 15, 2022

maybe the explicit pluginId is a bit overkill 🤷‍♂️ we'll see later if it's worth keeping

@slorber slorber merged commit b4d93b9 into main Jun 15, 2022
@slorber slorber deleted the jc/ts-4.7 branch June 15, 2022 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: maintenance This PR does not produce any behavior differences to end users when upgrading.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants