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

Use module: node16 in types #68

Merged
merged 3 commits into from
Jan 2, 2023
Merged

Use module: node16 in types #68

merged 3 commits into from
Jan 2, 2023

Conversation

Gerrit0
Copy link
Contributor

@Gerrit0 Gerrit0 commented Dec 31, 2022

Initial checklist

  • I read the support docs
  • I read the contributing guide
  • I agree to follow the code of conduct
  • I searched issues and couldn’t find anything (or linked relevant results below)
  • If applicable, I’ve added docs and tests

Description of changes

Adds a .js file extension to the type import for complex-types.d.ts. This is necessary for TypeScript projects using "module": "Node16" to compile without errors:

node_modules/mdast-util-to-hast/index.d.ts:5:26 - error TS2834: Relative import paths need explicit file
  extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding
  an extension to the import path.

5 export type Raw = import('./complex-types').Raw
                           ~~~~~~~~~~~~~~~~~

Yes, the .js file extension looks wrong... but it isn't. TypeScript will still resolve the import to the declaration file.

Without this change, the build still does not pass, due to three type errors, likely due to installing a newer TypeScript version than was used to write this package (package-lock.json is a good thing!), I opted not to fix this at this time.

cc: @gaurishhs

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Dec 31, 2022
Copy link
Member

@ChristianMurphy ChristianMurphy left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @Gerrit0!

Would it make sense to set the resolution in the TypeScript config file, so this is tested going forward?

"compilerOptions": {
"target": "ES2020",
"lib": ["ES2020"],
"module": "ES2020",
"moduleResolution": "node",


It looks like there is an unrelated typescript error, a breaking change in the latest minor TS release which will take some looking into. (Doesn't need to be a part of this PR, but if you have a moment to open a PR resolving it, it could accelerate being able to merge this PR 🙂 )

Copy link
Member

@ChristianMurphy ChristianMurphy left a comment

Choose a reason for hiding this comment

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

Thanks @Gerrit0 and @wooorm!

@wooorm wooorm changed the title Add file extension to complex-types import Use module: node16 in types Jan 2, 2023
@wooorm wooorm merged commit 6e38f21 into syntax-tree:main Jan 2, 2023
@wooorm wooorm added ☂️ area/types This affects typings 💪 phase/solved Post is done labels Jan 2, 2023
@github-actions

This comment has been minimized.

@github-actions github-actions bot removed the 🤞 phase/open Post is being triaged manually label Jan 2, 2023
@Gerrit0 Gerrit0 deleted the patch-1 branch January 2, 2023 19:48
@wooorm
Copy link
Member

wooorm commented Jan 2, 2023

Thanks, released in 12.2.5!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
☂️ area/types This affects typings 💪 phase/solved Post is done
Development

Successfully merging this pull request may close these issues.

4 participants