-
Notifications
You must be signed in to change notification settings - Fork 30.5k
Base MDX type tests on real world examples #68955
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
Base MDX type tests on real world examples #68955
Conversation
This bases the MDX type tests on real world examples. Different frameworks use different type definitions for the JSX namespace.
|
ts-eslint's support for project references is not so good; you'd need to set this up just like I did #68908 and put tsconfigs without references at the root. |
153524a to
c7666ca
Compare
Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
| namespace JSX { | ||
| type Element = runtime.JSX.Element; | ||
| type ElementClass = runtime.JSX.ElementClass; | ||
| type ElementType = runtime.JSX.ElementType; | ||
| type IntrinsicElements = runtime.JSX.IntrinsicElements; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was a bit sad to find out this is necessary. I initially thought this would work, but it doesn’t:
declare module 'mdx/types' {
import { JSX } from 'preact/jsx-runtime'
}|
I think to fix the current errors, you should go back to |
|
Seems like the test only fails due to the JSX namespace needing to be declared? |
|
The JSX namespace is declared in |
|
The one declared in the preact file is on the preact module, but |
|
Seems like it's passing; are you wanting this to get merged in? (It's currently a draft but seems good to me.) |
|
I think it’s good, but seeing Preact integration depends on declaration merging, I would like to add some docs for this. Also now that this works, I want to test Vue and Solid integration. I’m marking it Ready for review to ping other maintainers, see if they also think this is a good idea. |
|
@remcohaszing Thank you for submitting this PR! This is a live comment which I will keep updated. 1 package in this PR
Code ReviewsBecause this is a widely-used package, a DT maintainer will need to review it before it can be merged. You can test the changes of this PR in the Playground. Status
All of the items on the list are green. To merge, you need to post a comment including the string "Ready to merge" to bring in your changes. Diagnostic Information: What the bot saw about this PR{
"type": "info",
"now": "-",
"pr_number": 68955,
"author": "remcohaszing",
"headCommitOid": "d51924efb0e19162a72cc5cd33c738dae1ae6d8e",
"mergeBaseOid": "55df51f723ed778b0960e1fe3ae43a3590a88d58",
"lastPushDate": "2024-03-11T10:53:13.000Z",
"lastActivityDate": "2024-03-22T10:52:38.000Z",
"mergeOfferDate": "2024-03-22T00:06:29.000Z",
"mergeRequestDate": "2024-03-22T10:52:38.000Z",
"mergeRequestUser": "remcohaszing",
"hasMergeConflict": false,
"isFirstContribution": false,
"tooManyFiles": false,
"hugeChange": false,
"popularityLevel": "Critical",
"pkgInfo": [
{
"name": "mdx",
"kind": "edit",
"files": [
{
"path": "types/mdx/index.d.ts",
"kind": "definition"
},
{
"path": "types/mdx/package.json",
"kind": "package-meta-ok"
},
{
"path": "types/mdx/preact-tests.tsx",
"kind": "test"
},
{
"path": "types/mdx/react-tests.tsx",
"kind": "test"
},
{
"path": "types/mdx/tsconfig.json",
"kind": "package-meta-ok"
},
{
"path": "types/mdx/tsconfig.preact.json",
"kind": "package-meta",
"suspect": "not [the expected form](https://github.com/DefinitelyTyped/DefinitelyTyped#user-content-tsconfigjson) (check: `compilerOptions.jsxFactory`)"
},
{
"path": "types/mdx/tsconfig.react.json",
"kind": "package-meta-ok"
},
{
"path": "types/mdx/types.d.ts",
"kind": "definition"
}
],
"owners": [
"ChristianMurphy",
"remcohaszing",
"wooorm"
],
"addedOwners": [],
"deletedOwners": [],
"popularityLevel": "Critical"
}
],
"reviews": [
{
"type": "approved",
"reviewer": "jakebailey",
"date": "2024-03-22T00:05:46.000Z",
"isMaintainer": true
},
{
"type": "approved",
"reviewer": "ChristianMurphy",
"date": "2024-03-18T20:40:21.000Z",
"isMaintainer": false
}
],
"mainBotCommentID": 1997845374,
"ciResult": "pass"
} |
|
🔔 @ChristianMurphy @wooorm — please review this PR in the next few days. Be sure to explicitly select |
|
@remcohaszing Thank you for submitting this PR! This is a live comment which I will keep updated. 1 package in this PR
Code ReviewsBecause this is a widely-used package, a DT maintainer will need to review it before it can be merged. You can test the changes of this PR in the Playground. Status
All of the items on the list are green. To merge, you need to post a comment including the string "Ready to merge" to bring in your changes. Diagnostic Information: What the bot saw about this PR{
"type": "info",
"now": "-",
"pr_number": 68955,
"author": "remcohaszing",
"headCommitOid": "d51924efb0e19162a72cc5cd33c738dae1ae6d8e",
"mergeBaseOid": "55df51f723ed778b0960e1fe3ae43a3590a88d58",
"lastPushDate": "2024-03-11T10:53:13.000Z",
"lastActivityDate": "2024-03-22T10:52:38.000Z",
"mergeOfferDate": "2024-03-22T00:06:29.000Z",
"mergeRequestDate": "2024-03-22T10:52:38.000Z",
"mergeRequestUser": "remcohaszing",
"hasMergeConflict": false,
"isFirstContribution": false,
"tooManyFiles": false,
"hugeChange": false,
"popularityLevel": "Critical",
"pkgInfo": [
{
"name": "mdx",
"kind": "edit",
"files": [
{
"path": "types/mdx/index.d.ts",
"kind": "definition"
},
{
"path": "types/mdx/package.json",
"kind": "package-meta-ok"
},
{
"path": "types/mdx/preact-tests.tsx",
"kind": "test"
},
{
"path": "types/mdx/react-tests.tsx",
"kind": "test"
},
{
"path": "types/mdx/tsconfig.json",
"kind": "package-meta-ok"
},
{
"path": "types/mdx/tsconfig.preact.json",
"kind": "package-meta",
"suspect": "not [the expected form](https://github.com/DefinitelyTyped/DefinitelyTyped#user-content-tsconfigjson) (check: `compilerOptions.jsxFactory`)"
},
{
"path": "types/mdx/tsconfig.react.json",
"kind": "package-meta-ok"
},
{
"path": "types/mdx/types.d.ts",
"kind": "definition"
}
],
"owners": [
"ChristianMurphy",
"remcohaszing",
"wooorm"
],
"addedOwners": [],
"deletedOwners": [],
"popularityLevel": "Critical"
}
],
"reviews": [
{
"type": "approved",
"reviewer": "jakebailey",
"date": "2024-03-22T00:05:46.000Z",
"isMaintainer": true
},
{
"type": "approved",
"reviewer": "ChristianMurphy",
"date": "2024-03-18T20:40:21.000Z",
"isMaintainer": false
}
],
"mainBotCommentID": 1997845374,
"ciResult": "pass"
} |
|
@jakebailey Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review? |
|
🔔 @ChristianMurphy @wooorm — please review this PR in the next few days. Be sure to explicitly select |
|
@jakebailey Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review? |
|
I'm pretty sure if you set |
This used to be the case, but with frameworks moving away from the global Also DefinitelyTyped doesn’t allow specifying |
|
I also tried this: declare module "mdx/types" {
import { JSX } from 'preact/jsx-runtime'
}but that gave the type error |
|
@jakebailey @sandersn @weswigham is this good to go or does this need some work as suggested by @weswigham in #68955 (comment) to support supplying |
|
This PR is fine from my perspective, I believe we were just waiting for feedback from other MDX maintainers. |
sheetalkamat
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marking this as change needed so that its not on maintainer board. please merge main when one of MDX maintainer approves so we can approve this.
|
@remcohaszing One or more reviewers has requested changes. Please address their comments. I'll be back once they sign off or you've pushed new commits. Thank you! |
|
FWIW you can just move this over to the "needs review" column and it'll "bless" the PR to say "maintainer said okay", I'm pretty sure. |
ChristianMurphy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have access to the discord that initiated this PR to have the context.
Reading between the lines a bit, it seems to focus on adding preact testing?
I'm all for supporting the types of other frameworks.
But don't use them enough to offer much constructive review on this PR.
I'll approved to unblock if others are comfortable.
/cc @wooorm who have more thoughts on this
| img: CustomImageComponent, | ||
| // @ts-expect-error | ||
| video: CustomImageComponent, | ||
| input: CustomImageComponent, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there something about input that makes it a better test than video?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, apparently input props are assignable to image props in Preact.
The context is that I added to DT the ability to check with multiple different tsconfigs, which means projects can check with different settings and references. This was mainly for node to check with/without DOM types, but can also be used for MDX to test against react, preact, etc. |
|
Thanks for the context @jakebailey! That helps |
jakebailey
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't seem like there's going to be other feedback; going to approve this and you can feel free to merge if you believe that it's all good.
|
@remcohaszing: Everything looks good here. I am ready to merge this PR (at d51924e) on your behalf whenever you think it's ready. If you'd like that to happen, please post a comment saying:
and I'll merge this PR almost instantly. Thanks for helping out! ❤️ (@ChristianMurphy, @wooorm: you can do this too.) |
|
It looks like both Solid and Vue only work with the automatic runtime types, which are not allowed by dtslint. I’ll merge as-is. |
|
Ready to merge |
This bases the MDX type tests on real world examples. Different frameworks use different type definitions for the JSX namespace. This is what I envision the tests could look like.
Please fill in this template.
pnpm test <package to test>.If changing an existing definition:
package.json.cc @jakebailey