react-script-hook
react-script-hook copied to clipboard
Script attribute types are treated as having an unknown shape
The current type used for ScriptProps is as follows:
export interface ScriptProps {
src: HTMLScriptElement['src'] | null;
checkForExisting?: boolean;
[key: string]: any;
}
Where the type of attributes added to the <script> tag with the exception of the src key are [key: string]: any. As the attributes are specifically added to a <script> tag I believe a better typing might be provided by the following:
type ScriptAttributes = Omit<HTMLScriptElement, 'src'>;
export interface ScriptProps extends ScriptAttributes {
src: HTMLScriptElement['src'] | null;
checkForExisting?: boolean;
}
With src omitted for the sake of not stepping on the logic that makes use of the null value.