Closed
Description
Bug Report
π Search Terms
recursive type constraint
π Version & Regression Information
- This changed between versions 4.9 and 5.0 Beta
β― Playground Link
Only happens in multi files projects in VS Code. Repo: https://github.com/dragomirtitian/recursive-type-constarint-bug-ts-5.0
π» Code
/// types.ts
export type<T extends Record<string, (...params: unknown[]) => unknown>> = {
[key in keyof T]: T[key];
};
/// index.ts
export declare const value2: {
sliceSelectors: <FuncMap extends import('./types').SelectorMap<FuncMap>>(selectorsBySlice: FuncMap) => { [P in keyof FuncMap]: Parameters<FuncMap[P]> };
};
π Actual behavior
When you first open the project in VS code you get the errors below. Any further editing of the file makes the error s go away.
Type parameter 'FuncMap' has a circular constraint.
Type 'FuncMap[P]' does not satisfy the constraint '(...args: any) => any'.
Type 'FuncMap[keyof FuncMap]' is not assignable to type '(...args: any) => any'.
Type 'FuncMap[string] | FuncMap[number] | FuncMap[symbol]' is not assignable to type '(...args: any) => any'.
Type 'FuncMap[string]' is not assignable to type '(...args: any) => any'.
Also happens in a custom build tool using the compiler API
π Expected behavior
The code either fails all the time or type checks all the time
Note: The circular constraint which is present above and seems to trigger the bug doesnβt seem to make much sense in our case, so we took the opportunity to clean up the types, so this is not blocking for us, but the behavior is still very strange.