fast icon indicating copy to clipboard operation
fast copied to clipboard

fix: typescript error TS2344 in fast-foundation.d.ts with TypeScript 4.8.2

Open jedwards1211 opened this issue 3 years ago • 4 comments

🐛 Bug Report

Starting with TypeScript 4.8.2 there are errors like

node_modules/.pnpm/@[email protected]/node_modules/@microsoft/fast-foundation/dist/fast-foundation.d.ts:2252:66 - error TS2344: Type 'T' does not satisfy the constraint 'string | number | boolean | symbol | any[] | Uint8Array | ({ createCSS?(): string; } & Record<PropertyKey, any>) | null'.
  Type 'T' is not assignable to type '{ createCSS?(): string; } & Record<PropertyKey, any>'.
    Type 'T' is not assignable to type '{ createCSS?(): string; }'.

2252 declare function create<T>(nameOrConfig: string): CSSDesignToken<T>;

  node_modules/.pnpm/@[email protected]/node_modules/@microsoft/fast-foundation/dist/fast-foundation.d.ts:2252:25
    2252 declare function create<T>(nameOrConfig: string): CSSDesignToken<T>;
                                 ~
    This type parameter might need an `extends { createCSS?(): string; }` constraint.
  node_modules/.pnpm/@[email protected]/node_modules/@microsoft/fast-foundation/dist/fast-foundation.d.ts:2252:25
    2252 declare function create<T>(nameOrConfig: string): CSSDesignToken<T>;
                                 ~
    This type parameter might need an `extends { createCSS?(): string; } & Record<PropertyKey, any>` constraint.
  node_modules/.pnpm/@[email protected]/node_modules/@microsoft/fast-foundation/dist/fast-foundation.d.ts:2252:25
    2252 declare function create<T>(nameOrConfig: string): CSSDesignToken<T>;
                                 ~
    This type parameter might need an `extends string | number | boolean | symbol | any[] | Uint8Array | ({ createCSS?(): string; } & Record<PropertyKey, any>) | null` constraint.

CSSDesignToken is declared as

export declare interface CSSDesignToken<T extends string | number | boolean | BigInteger | null | Array<any> | symbol | ({
    createCSS?(): string;
} & Record<PropertyKey, any>)> extends DesignToken<T>, CSSDirective {

💻 Repro or Code Sample

TS Playground Example of the error

🌍 Your Environment

TypeScript 4.8.2

jedwards1211 avatar Sep 08 '22 15:09 jedwards1211

[Edit] Never mind, I also experienced this with 4.8. skipLibCheck resolves the issue if necessary.

TrevorKarjanis avatar Nov 03 '22 18:11 TrevorKarjanis

Thanks for confirming the issue beginning in 4.8!

chrisdholt avatar Jan 15 '23 02:01 chrisdholt

@jedwards1211 this issue should now be resolved with merging of #6779 and release @microsoft/[email protected]

rajsite avatar Oct 11 '23 22:10 rajsite

@chrisdholt we've been having good success with the changes from #6779 so I think that resolves this issue, i.e. fixed in @microsoft/[email protected]

rajsite avatar Oct 16 '23 21:10 rajsite

Unfortunately @microsoft/fast-foundation is being deprecated, refer to #6955.

janechu avatar May 29 '24 17:05 janechu