I have a Node project running an Express server that, when queried a news article with /amp
in the URL, returns the AMP version of that article.
Due to the request of a client, these AMP articles are built using React components that are in the end rendered to static markup.
Here is one of the components:
import * as React from 'react';
import { Article_modulesByArticleId_edges_node } from '../../data/__generated__/Article';
// GraphQL auto generated type for the data that is sent to this component
type Props = {
module: Article_modulesByArticleId_edges_node;
};
export default (props: Props) => {
const image = props.module.image;
if (!image || !image.url || !image.title || !image.copyright) {
return "";
}
return <amp-img alt={image.title} src={image.url} ... />
};
The problem?
The project also uses TypeScript, which I am not overly familiar with.
When I try to use a custom AMP element, TypeScript throws this error message:
[ts] Property 'amp-img' does not exist on type 'JSX.IntrinsicElements'.
I haven't been able to find any node packages with the AMP types defined, and overall not a lot of discussion about TypeScript and AMP.
Does anyone have any suggestions?
Do I have to write my own declarations for AMP elements?