react-helmet
react-helmet copied to clipboard
HelmetData interface incorrect
Do you want to request a feature or report a bug? Bug
The export interface used with Helmet.peek() is incorrect. The current interface:
export class Helmet extends React.Component<HelmetProps> {
static peek(): HelmetData;
static rewind(): HelmetData;
static renderStatic(): HelmetData;
static canUseDOM: boolean;
}
export interface HelmetData {
base: HelmetDatum;
bodyAttributes: HelmetHTMLBodyDatum;
htmlAttributes: HelmetHTMLElementDatum;
link: HelmetDatum;
meta: HelmetDatum;
noscript: HelmetDatum;
script: HelmetDatum;
style: HelmetDatum;
title: HelmetDatum;
titleAttributes: HelmetDatum;
}
However when using this in a mock:
const helmet = Helmet.peek()
console.log(helmet)
The following is outputted:
{
baseTag: [],
bodyAttributes: {},
defer: true,
encode: true,
htmlAttributes: { lang: 'en' },
linkTags: [],
metaTags: [
{ name: 'description', content: 'passed description' },
{ property: 'og:site_name', content: 'site title' },
{ property: 'og:title', content: 'passed title' },
{ property: 'og:description', content: 'passed description' },
{ property: 'og:type', content: 'website' },
{ name: 'twitter:card', content: 'summary' },
{ name: 'twitter:creator', content: 'author' },
{ name: 'twitter:title', content: 'site title' },
{ name: 'twitter:description', content: 'passed description' }
],
noscriptTags: [],
onChangeClientState: [Function (anonymous)],
scriptTags: [],
styleTags: [],
title: 'passed title | site title',
titleAttributes: {}
}
It appears that metaTags needs to be added to the HelmData interface.
I assume this is about the typescript types, vs library usage. The types are not (yet) maintained by this project.
See https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-helmet/
Feel free to PR the types to this lib and remove them from DefinitelyTyped
ref: DefinitelyTyped/DefinitelyTyped#52306