我有一个.mdx
文件。
有以下内容mdx.d.ts
:
/// <reference types="@mdx-js/loader" />
import { ComponentType } from "react";
declare module '*.mdx' {
const Component: ComponentType;
export default Component;
}
使
import Comp from "./Comp.mdx";
throw "TS2307: 找不到模块 './Comp.mdx' 或其对应的类型声明。"
然而,只有以下作品:
declare module '*.mdx';
这是为什么?
tsconfig.json
:
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"include": ["**/*.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}