Skip to content

Commit 04245e6

Browse files
JakeGinnivanstaylor
authored andcommitted
Copies react-helmet types across so incorrect types can be removed
rewind etc are not valid for this library, forking the react-helmet types into this project fixes #61
1 parent e02564f commit 04245e6

File tree

1 file changed

+76
-5
lines changed

1 file changed

+76
-5
lines changed

index.d.ts

Lines changed: 76 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,86 @@
11
declare module 'react-helmet-async' {
22
import * as React from 'react';
3-
import { Helmet, HelmetData } from 'react-helmet';
4-
export { Helmet };
53

6-
export type FilledContext = {
4+
interface OtherElementAttributes {
5+
[key: string]: string | number | boolean | null | undefined;
6+
}
7+
8+
type HtmlProps = JSX.IntrinsicElements['html'] & OtherElementAttributes;
9+
10+
type BodyProps = JSX.IntrinsicElements['body'] & OtherElementAttributes;
11+
12+
type LinkProps = JSX.IntrinsicElements['link'];
13+
14+
type MetaProps = JSX.IntrinsicElements['meta'];
15+
16+
export interface HelmetTags {
17+
baseTag: Array<any>;
18+
linkTags: Array<HTMLLinkElement>;
19+
metaTags: Array<HTMLMetaElement>;
20+
noscriptTags: Array<any>;
21+
scriptTags: Array<HTMLScriptElement>;
22+
styleTags: Array<HTMLStyleElement>;
23+
}
24+
25+
export interface HelmetProps {
26+
async?: boolean;
27+
base?: any;
28+
bodyAttributes?: BodyProps;
29+
defaultTitle?: string;
30+
defer?: boolean;
31+
encodeSpecialCharacters?: boolean;
32+
htmlAttributes?: HtmlProps;
33+
onChangeClientState?: (newState: any, addedTags: HelmetTags, removedTags: HelmetTags) => void;
34+
link?: LinkProps[];
35+
meta?: MetaProps[];
36+
noscript?: Array<any>;
37+
script?: Array<any>;
38+
style?: Array<any>;
39+
title?: string;
40+
titleAttributes?: Object;
41+
titleTemplate?: string;
42+
}
43+
44+
export class Helmet extends React.Component<HelmetProps> {
45+
}
46+
47+
export interface HelmetData {
48+
base: HelmetDatum;
49+
bodyAttributes: HelmetHTMLBodyDatum;
50+
htmlAttributes: HelmetHTMLElementDatum;
51+
link: HelmetDatum;
52+
meta: HelmetDatum;
53+
noscript: HelmetDatum;
54+
script: HelmetDatum;
55+
style: HelmetDatum;
56+
title: HelmetDatum;
57+
titleAttributes: HelmetDatum;
58+
}
59+
60+
export interface HelmetDatum {
61+
toString(): string;
62+
toComponent(): React.Component<any>;
63+
}
64+
65+
export interface HelmetHTMLBodyDatum {
66+
toString(): string;
67+
toComponent(): React.HTMLAttributes<HTMLBodyElement>;
68+
}
69+
70+
export interface HelmetHTMLElementDatum {
71+
toString(): string;
72+
toComponent(): React.HTMLAttributes<HTMLHtmlElement>;
73+
}
74+
75+
export interface FilledContext {
776
helmet: HelmetData;
877
};
978

10-
type ProviderProps = {
79+
interface ProviderProps {
1180
context?: {};
1281
};
1382

14-
export const HelmetProvider: React.ComponentClass<ProviderProps>;
83+
export class HelmetProvider extends React.Component<ProviderProps> {
84+
static canUseDOM = canUseDOM;
85+
}
1586
}

0 commit comments

Comments
 (0)