fix: typescript error TS2344 in fast-foundation.d.ts with TypeScript 4.8.2
🐛 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
[Edit] Never mind, I also experienced this with 4.8. skipLibCheck resolves the issue if necessary.
Thanks for confirming the issue beginning in 4.8!
@jedwards1211 this issue should now be resolved with merging of #6779 and release @microsoft/[email protected]
@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]
Unfortunately @microsoft/fast-foundation is being deprecated, refer to #6955.