One of the declarations in my ./src/types.d.ts
file includes various modules:
/// <reference types="@emotion/react/types/css-prop" />
import '@emotion/react';
import { PureComponent, SVGProps } from 'react';
declare module '*.svg' {
export class ReactComponent extends PureComponent<SVGProps<SVGSVGElement>> {}
}
declare module '*.ttf';
declare module '*.eot';
declare module '*.woff';
declare module '*.woff2';
Upon running tsc --noEmit
, errors like ...
src/fonts/fonts.ts:39:31 - error TS2307: Cannot find module './pt-sans-v12-latin-ext_latin-regular.woff' or its corresponding type declarations.
39 import PTSansregularWOFF from './pt-sans-v12-latin-ext_latin-regular.woff';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/fonts/fonts.ts:40:32 - error TS2307: Cannot find module './pt-sans-v12-latin-ext_latin-regular.woff2' or its corresponding type declarations.
40 import PTSansregularWOFF2 from './pt-sans-v12-latin-ext_latin-regular.woff2';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/layouts/default/NavigationBar.tsx:4:41 - error TS2307: Cannot find module '../../images/brand.svg' or its corresponding type declarations.
4 import { ReactComponent as Brand } from '../../images/brand.svg';
~~~~~~~~~~~~~~~~~~~~~~~~
... are displayed.
This is my tsconfig.json
:
{
"include": ["./src/**/*", "./.gatsby/**/*", "./*.ts", "./plugins/**/*"],
"files": ["./src/types.d.ts"],
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"lib": ["dom", "ES2017", "ES2019"],
"jsx": "react-jsx",
"strict": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noEmit": true,
"skipLibCheck": true,
"moduleResolution": "node",
"resolveJsonModule": true
}
}
This is the structure of my file tree: https://i.stack.imgur.com/Fv1pF.png
How can I ensure Typescript locates the corresponding type declarations?
Interestingly, defining the interface Theme
in @emotion/react
within my types.d.ts
has an effect on other parts.