Cannot import local fonts with TypeScript

You need to declare the font file formats as modules so that TypeScript can parse them correctly.

create a fonts.d.ts file and add the following to it

declare module '*.woff';
declare module '*.woff2';

It tells TypeScript that the font filetypes are valid import modules.

The “d.ts” file format is used to provide typescript type information about an API that’s written in JavaScript, or the shape of the third party imports.

Make sure that the types file is considered in the include section in tsconfig.json. A nice approach is to have a root typings directory in your project, then append typings/**/*.d.ts on include.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)