react-meta-tags
react-meta-tags copied to clipboard
MetaTags in TypeScript
How do i implement this in .net core with typescript ? i cant import since it has an any type and if i require it it only gives me an error that is does not have a call signature or construct.
You can just explicitly cast it as any or declare the module in override.d.ts
I don't know why it is not included in the repo itself.
create a file "react-meta-tags.d.ts" and paste the below content.
// Type definitions for react-meta-tags 0.7.4
// Project: react-meta-tags
// Definitions by: Siraj Alam https://github.com/sirajalam049
declare module "react-meta-tags" {
export default class Meta extends React.Component { }
}
This does work, but it's not ok to ask people to put your username in the file just for answering. 😒
@doublejosh haha, funny you mentioned it. The snippet I gave above is pasted from the file I created, using. TypeScript types definition template
OK, you can put your name in your files if you want, but it's weirdly self-promotional to instruct people to do so.
Another suggested version of react-meta-tags.d.ts
declaration file with more details:
interface ExtractFunctionType {
(elements: React.ReactElement | React.ReactElement[]): void;
}
declare module "react-meta-tags" {
export type ExtractFunction = ExtractFunctionType;
export class MetaTagsContext extends React.Component<{
extract: ExtractFunctionType;
}> {};
export class MetaTags extends React.Component {};
export class ReactTitle extends React.Component<{ title: string }> {
};
export default MetaTags;
}
declare module "react-meta-tags/server" {
export interface MetaTagsInstance {
extract: ExtractFunctionType;
renderToString: () => string;
getTags: () => React.ReactElement[];
}
const MetaTagsServer: () => MetaTagsInstance
export default MetaTagsServer;
}
Sorry, butt IDK where to put this file in? node_modules or somewhere else, please?
@trdbau You can just create a d.ts file anywhere in the folder. I would only suggest to do as global as possible, to give yourself the advantage to find it back easily.
See the image below for example, this way should work