- 在基础中打开VS Code
- 打开文件 packages/core/components/Checkbox.jsx
- 转到第100行
- 进行更改
- <Label {...style} checked={checked} disabled={disabled}>
+ <Label style={style} checked={checked} disabled={disabled}>
观察错误信息:
No overload matches this call.
Overload 1 of 2, '(props: Pick<Pick<Pick<DetailedHTMLProps<LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "form" | ... 255 more ... | "htmlFor"> & { ...; }, "form" | ... 256 more ... | "htmlFor"> & Partial<...>, "form" | ... 256 more ... | "htmlFor"> & { ...; } & { ...; }): ReactElement<...>', gave the following error.
Type '{ children: Element[]; style: any; checked: any; disabled: any; }' is not assignable to type 'IntrinsicAttributes & Pick<Pick<Pick<DetailedHTMLProps<LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "form" | ... 255 more ... | "htmlFor"> & { ...; }, "form" | ... 256 more ... | "htmlFor"> & Partial<...>, "form" | ... 256 more ... | "htmlFor"> & { ...; } & { ...; }'.
Property 'checked' does not exist on type 'IntrinsicAttributes & Pick<Pick<Pick<DetailedHTMLProps<LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "form" | ... 255 more ... | "htmlFor"> & { ...; }, "form" | ... 256 more ... | "htmlFor"> & Partial<...>, "form" | ... 256 more ... | "htmlFor"> & { ...; } & { ...; }'.
Overload 2 of 2, '(props: StyledComponentPropsWithAs<"label", any, {}, never>): ReactElement<StyledComponentPropsWithAs<"label", any, {}, never>, string | ... 1 more ... | (new (props: any) => Component<...>)>', gave the following error.
Type '{ children: Element[]; style: any; checked: any; disabled: any; }' is not assignable to type 'IntrinsicAttributes & Pick<Pick<Pick<DetailedHTMLProps<LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "form" | ... 255 more ... | "htmlFor"> & { ...; }, "form" | ... 256 more ... | "htmlFor"> & Partial<...>, "form" | ... 256 more ... | "htmlFor"> & { ...; } & { ...; }'.
Property 'checked' does not exist on type 'IntrinsicAttributes & Pick<Pick<Pick<DetailedHTMLProps<LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "form" | ... 255 more ... | "htmlFor"> & { ...; }, "form" | ... 256 more ... | "htmlFor"> & Partial<...>, "form" | ... 256 more ... | "htmlFor"> & { ...; } & { ...; }'.ts(2769)
2条答案
按热度按时间rxztt3cl1#
这是否被认为是相同的错误?
http://www.typescriptlang.org/play/index.html#code/JYOwLgpgTgZghgYwgAgPIAczAPYgM7IDeAUMsiHALYQBcyeYUoA5gNzEC+xoksiKAJQh4ArgBswRZFx7R4SZAOzYwANThiRKQtOLEYIkAiy5kMAIwAKAJR0lK9ZojsDRkyDNW4UZnQZMQZltFYXEwF0NjHA8LS29fNExovGChUQkIt2jPOJ8Afj9GFmQAH0T3FLtQiSJSZGAYZFzmZABeVuRDABMIGFAILutasjIoCDARKA9CDnYyDmQIMTxtOtHxyZiAJmbrOd0ufUj3Mx34woCgqvTwo6zTGDOfOgwK1Orb1yiHp4T-YrKr2S7xuw2QYwmUyIs04QA
qxgroojn2#
是的,我在使用https://github.com/ReactTraining/history/时遇到了这个问题。
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/1f36fb3afd908ffa206570c4f0ecae4178f6944e/types/history/index.d.ts#L15-L16
push
有两个重载,我传递了LocationDescriptor<S = LocationState> = Path | LocationDescriptorObject<S>;
给它。但是当我传递LocationDescriptor
给push方法时,它抛出了相同的错误。