From 4b6756548680a242aaf29d7a8ee3d20b017a89ca Mon Sep 17 00:00:00 2001 From: Justin Hall Date: Wed, 30 Oct 2019 12:25:56 -0600 Subject: [PATCH] [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-*`. --- types/react-helmet/index.d.ts | 17 +++++++++-------- types/react-helmet/react-helmet-tests.tsx | 4 ---- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/types/react-helmet/index.d.ts b/types/react-helmet/index.d.ts index 42078029cf..9b5abc9690 100644 --- a/types/react-helmet/index.d.ts +++ b/types/react-helmet/index.d.ts @@ -6,14 +6,19 @@ // Kok Sam // Yui T. // Yamagishi Kazutoshi +// Justin Hall // 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; diff --git a/types/react-helmet/react-helmet-tests.tsx b/types/react-helmet/react-helmet-tests.tsx index f772f62978..94b0b8b2d5 100644 --- a/types/react-helmet/react-helmet-tests.tsx +++ b/types/react-helmet/react-helmet-tests.tsx @@ -108,10 +108,6 @@ function HTML() { ; -// $ExpectError -; -// $ExpectError -; // $ExpectError ; // $ExpectError