Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Property 'fonts' does not exist on type 'Document'?

Tags:

i use typescript in vue and use document.fonts api but console this log

Property 'fonts' does not exist on type 'Document'
like image 395
freyhill Avatar asked Apr 17 '19 08:04

freyhill


2 Answers

Experimental APIs aren't in the lib file.

You can fix it with: (document as any).fonts

like image 177
Marcos Mezzabotta Avatar answered Nov 15 '22 07:11

Marcos Mezzabotta


For me and according to this thread, was enough to install the following package:

npm i -S @types/css-font-loading-module

And then on the .ts file where you see the error, import the next line:

import type { } from "css-font-loading-module";
like image 44
Mauro Bilotti Avatar answered Nov 15 '22 06:11

Mauro Bilotti