@@ -42,11 +42,11 @@ export default async function load(fontFamily: string, cacheSize: number): Promi
4242 if ( status && status . state !== 'granted' ) {
4343 throw new Error ( 'Permission to access local fonts not granted.' ) ;
4444 }
45- } catch ( err : any ) {
45+ } catch ( err : unknown ) {
4646 // A `TypeError` indicates the 'local-fonts'
4747 // permission is not yet implemented, so
4848 // only `throw` if this is _not_ the problem.
49- if ( err . name !== 'TypeError' ) {
49+ if ( err instanceof Error && err . name !== 'TypeError' ) {
5050 throw err ;
5151 }
5252 }
@@ -60,8 +60,10 @@ export default async function load(fontFamily: string, cacheSize: number): Promi
6060 fonts [ metadata . family ] . push ( metadata ) ;
6161 }
6262 fontsPromise = Promise . resolve ( fonts ) ;
63- } catch ( err : any ) {
64- console . error ( err . name , err . message ) ;
63+ } catch ( err : unknown ) {
64+ if ( err instanceof Error ) {
65+ console . error ( err . name , err . message ) ;
66+ }
6567 }
6668 }
6769 // Latest proposal https://bugs.chromium.org/p/chromium/issues/detail?id=1312603
@@ -76,8 +78,10 @@ export default async function load(fontFamily: string, cacheSize: number): Promi
7678 fonts [ metadata . family ] . push ( metadata ) ;
7779 }
7880 fontsPromise = Promise . resolve ( fonts ) ;
79- } catch ( err : any ) {
80- console . error ( err . name , err . message ) ;
81+ } catch ( err : unknown ) {
82+ if ( err instanceof Error ) {
83+ console . error ( err . name , err . message ) ;
84+ }
8185 }
8286 }
8387 fontsPromise ??= Promise . resolve ( { } ) ;
0 commit comments