-
Notifications
You must be signed in to change notification settings - Fork 27.6k
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
fix(types): allow other attributes on script component #26290
Conversation
Thank you. Looks good to me! |
This one can be merged :) |
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.
The current <script>
and <Script>
have the same properties due to the extends ScriptHTMLAttributes
here.
So if you were setting unknown props on <script>
you would get the same TS error as <Script>
.
Similarly, this is the same error you would get for <Image>
with unknown props.
If for some reason there are props missing, its best to get this changed upstream in the ScriptHTMLAttributes
interface via @types/react
@styfle So is there no fix to this? I am assuming what you are saying essentially doesn't allow me to use the custom attributes on Any way to work around that as I feel this isn't going to be merged? Or do I need to send a PR here but don't know if it'll be accepted either? |
Yep, DefinitelyTyped is the correct repository 👍 |
Confused 🤔 Do I send this PR there? |
Yes if there is a prop missing from the If you want to define custom types, you can extend the internal Next.js type declare module "next/script" {
interface Props {
someNewProp?: string
}
} Although now that I see this, we need to fix the interface name in PR #26990 so it will become: declare module "next/script" {
interface ScriptProps {
someNewProp?: string
}
} |
This will ensure `next/script` follows the same naming convention as `next/image`. For example: ```js import Image, { ImageProps } from 'next/image' import Script, { ScriptProps } from 'next/script' ``` Fixes #26290
This will ensure `next/script` follows the same naming convention as `next/image`. For example: ```js import Image, { ImageProps } from 'next/image' import Script, { ScriptProps } from 'next/script' ``` Fixes vercel#26290
This allows for other attributes on the script component (as the docs say) to exist.
NOTE: This is my first PR, so I hope I didn't do anything wrong in the contrib process... I didn't add integration tests, because this is a types-only change, but could add one if required (I would need help though).
fixes #26236
Bug
fixes #number