I am facing an issue with importing a .mdx
file.
When I include the following in my mdx.d.ts
:
/// <reference types="@mdx-js/loader" />
import { ComponentType } from "react";
declare module '*.mdx' {
const Component: ComponentType;
export default Component;
}
and try to import it like this:
import Comp from "./Comp.mdx";
I get an error saying "TS2307: Cannot find module './Comp.mdx' or its corresponding type declarations."
However, if I only have the following declaration:
declare module '*.mdx';
It works fine. Can anyone explain why?
Here is my 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"]
}