Skip to content

Typing inaccuracies does not allow for configureFonts to be used with MD2 under TypeScript 5.0 #3763

@NightScript370

Description

@NightScript370

Current behaviour

configureFonts's typings does not calculate isV3 correctly, meaning that it will fail with any Material Design 2 configuration

Expected behaviour

configureFonts should allow me to insert a Material Design 2 font configuration if the isV3 flag is set correctly

How to reproduce?

  1. Copy the code from the documentation
  2. Paste it into a brand new file anywhere with the codebase, as long as the dependencies can be found
  3. Remove the third line; ./src/App is not a guaranteed file and very much example exclusive
  4. Remove the export default lines at the bottom; we're trying to find type errors.

Congrats; we now have documentation-sourced code that crashes on us.

Preview

image

Underlined under config:

No overload matches this call.
The last overload gave the following error.
Type '{ web: { regular: { fontFamily: string; fontWeight: string; }; medium: { fontFamily: string; fontWeight: string; }; light: { fontFamily: string; fontWeight: string; }; thin: { fontFamily: string; fontWeight: string; }; }; ios: { ...; }; android: { ...; }; }' is not assignable to type 'Record<string, MD3Type>'.
Property 'web' is incompatible with index signature.
Type '{ regular: { fontFamily: string; fontWeight: string; }; medium: { fontFamily: string; fontWeight: string; }; light: { fontFamily: string; fontWeight: string; }; thin: { fontFamily: string; fontWeight: string; }; }' is missing the following properties from type 'MD3Type': fontFamily, letterSpacing, fontWeight, lineHeight, fontSize
Type 'false' is not assignable to type 'true'.ts(2769)
fonts.d.ts(78, 5): The expected type comes from property 'config' which is declared here on type '{ config: Record<string, MD3Type>; isV3?: true | undefined; }'
fonts.d.ts(77, 25): The last overload is declared here.

Underlined under isV3:

No overload matches this call.
The last overload gave the following error.
Type '{ web: { regular: { fontFamily: string; fontWeight: string; }; medium: { fontFamily: string; fontWeight: string; }; light: { fontFamily: string; fontWeight: string; }; thin: { fontFamily: string; fontWeight: string; }; }; ios: { ...; }; android: { ...; }; }' is not assignable to type 'Record<string, MD3Type>'.
Property 'web' is incompatible with index signature.
Type '{ regular: { fontFamily: string; fontWeight: string; }; medium: { fontFamily: string; fontWeight: string; }; light: { fontFamily: string; fontWeight: string; }; thin: { fontFamily: string; fontWeight: string; }; }' is missing the following properties from type 'MD3Type': fontFamily, letterSpacing, fontWeight, lineHeight, fontSize
Type 'false' is not assignable to type 'true'.ts(2769)
fonts.d.ts(79, 5): The expected type comes from property 'isV3' which is declared here on type '{ config: Record<string, MD3Type>; isV3?: true | undefined; }'
fonts.d.ts(77, 25): The last overload is declared here.

What have you tried so far?

Use official code from the people who provided the service; that proved the same thing.

Your Environment

The standard-table is non-applicable for this instance. Since this is a type error, I am using VSCodium 1.76.2's Intellisense under TypeScript 5.0.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions