[react-helmet] relax htmlAttributes and bodyAttributes types (#39983)

* style(react-helmet): format with prettier

* fix(react-helmet): relax htmlAttributes and bodyAttributes types

This preserves type-checking of known attributes but also allows for arbitrary attributes like
`data-*`.
This commit is contained in:
Justin Hall
2019-10-30 11:25:56 -07:00
committed by Jesse Trinity
parent a04f0db950
commit 4b67565486
2 changed files with 9 additions and 12 deletions
+9 -8
View File
@@ -6,14 +6,19 @@
// Kok Sam <https://github.com/sammkj>
// Yui T. <https://github.com/yuit>
// Yamagishi Kazutoshi <https://github.com/ykzts>
// Justin Hall <https://github.com/wKovacs64>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import * as React from "react";
import * as React from 'react';
type HtmlProps = JSX.IntrinsicElements['html'];
type HtmlProps = JSX.IntrinsicElements['html'] & {
[key: string]: string;
};
type BodyProps = JSX.IntrinsicElements['body']
type BodyProps = JSX.IntrinsicElements['body'] & {
[key: string]: string;
};
type LinkProps = JSX.IntrinsicElements['link'];
@@ -36,11 +41,7 @@ export interface HelmetProps {
defer?: boolean;
encodeSpecialCharacters?: boolean;
htmlAttributes?: HtmlProps;
onChangeClientState?: (
newState: any,
addedTags: HelmetTags,
removedTags: HelmetTags,
) => void;
onChangeClientState?: (newState: any, addedTags: HelmetTags, removedTags: HelmetTags) => void;
link?: LinkProps[];
meta?: MetaProps[];
noscript?: Array<any>;
@@ -108,10 +108,6 @@ function HTML() {
<html lang="en" />
</HelmetDefaultExport>;
// $ExpectError
<Helmet htmlAttributes={{ invalidProp: 'foo' }} />;
// $ExpectError
<Helmet bodyAttributes={{ invalidProp: 'foo' }} />;
// $ExpectError
<Helmet link={[ invalidProp: 'foo' ]} />;
// $ExpectError