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

Run TypeScript on the types #1042

Merged
merged 4 commits into from
May 10, 2024
Merged

Run TypeScript on the types #1042

merged 4 commits into from
May 10, 2024

Conversation

sindresorhus
Copy link
Owner

tsd only validates the types, it doesn't compile the code, so running TS too is helpful (and would have caught 3bdab60).

@sindresorhus sindresorhus requested a review from ehmicky May 9, 2024 19:14
@sindresorhus
Copy link
Owner Author

Not sure why this affects XO.

@ehmicky
Copy link
Collaborator

ehmicky commented May 9, 2024

I was about to open a PR doing exactly this! :)
It is unfortunate that tsd did not catch the typing bugs from 9.0.0. I was thinking of opening an issue on tsd, since ideally those should have been caught by tsd.

The change in xo behavior is probably due to the addition of tsconfig.json.

Maybe this is related to #1040? Let's see if the problem persists after merging #1043.

@sindresorhus
Copy link
Owner Author

I was thinking of opening an issue on tsd, since ideally those should have been caught by tsd.

Yeah, would be nice if tsd could run TS too.

@sindresorhus
Copy link
Owner Author

Maybe this is related to #1040? Let's see if the problem persists after merging #1043.

Still failing on the same.

@ehmicky
Copy link
Collaborator

ehmicky commented May 9, 2024

Looking into it now. 👀

@ehmicky
Copy link
Collaborator

ehmicky commented May 9, 2024

The problem was that tsconfig.json adds strict: true (which is good).

One of the type tests needed to be tweaked to avoid an implicit conversion to any, which cannot be avoided due to how instanceof Error narrowing works in TypeScript.

tsconfig.json Outdated
"compilerOptions": {
"module": "nodenext",
"moduleResolution": "nodenext",
"moduleDetection": "force",
Copy link
Collaborator

@ehmicky ehmicky May 9, 2024

Choose a reason for hiding this comment

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

The default value of moduleDetection is auto, which uses the package.json type field when module is nodenext. Since we use type: 'module' in package.json, it seems like we could remove the moduleDetection: "force" line? tsc seems to work without it.

@sindresorhus sindresorhus merged commit e2903e9 into main May 10, 2024
11 of 12 checks passed
@sindresorhus sindresorhus deleted the ts branch May 10, 2024 05:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants