我有一个运行快速服务器的节点项目,当在 url 中查询带有 /amp 的新闻文章时,会返回该文章的 amp 版本。
由于客户的要求,这些 amp 文章是使用 React 组件构建的,这些组件最终呈现为静态标记。这是其中一个组件:
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} ... />
};Run Code Online (Sandbox Code Playgroud)
问题?该项目还使用了我不太熟悉的打字稿。
当我尝试使用自定义 AMP-HTML 元素时,打字稿会抛出以下错误消息:
[ts] Property …Run Code Online (Sandbox Code Playgroud)