-
Notifications
You must be signed in to change notification settings - Fork 8
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
Restrict usage of global React object #3376
base: next
Are you sure you want to change the base?
Conversation
db79eae
to
c3672b2
Compare
c3672b2
to
3322719
Compare
3322719
to
171cb4b
Compare
@@ -1,5 +1,6 @@ | |||
/// <reference types="@comet/admin-theme" /> | |||
|
|||
// eslint-disable-next-line no-restricted-globals |
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 could not get it to work, when removing the React.
usage here.
When its removed, there is an error, that the ref
prop is missing in CustomInputProps
.
And when the two types are imported import { type DetailedHTMLProps, type InputHTMLAttributes } from "react";
there is an error, that the added prop webkitdirectory
is not found.
Do you have an idea what's going on here? Can we leave the React.
usage here in the vendor.d.ts file (in the typedefinitions React.
usage seems common?)
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.
This should work:
/// <reference types="@comet/admin-theme" />
import { type HTMLAttributes } from "react";
declare module "react" {
interface InputHTMLAttributes<T> extends HTMLAttributes<T> {
// extends React's HTMLAttributes
directory?: string;
webkitdirectory?: string;
}
}
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.
Can we leave the React. usage here in the vendor.d.ts file (in the typedefinitions React. usage seems common?)
We don't need it in other .d.ts files 🤔 Maybe we should add explicit imports to all .d.ts files, otherwise probably the namespace is still used?
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.
Looks good. We need to decide how to handle *.d.ts
files though.
Description
follow up PR for the restriction of the React barrel import: also restrict the usage of the global React object.