You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In declarations, the type for a is printed as a: () => T extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? any : V : V : V : V : V : V : V : V : V : V : T;
π Expected behavior
Recursive can't be represented without falling back to any (as seen above) so it should just be an error instead of silently to any
Generally, I feel like it'd be even better to always emit some sort of declaration error whenever declaration emit synthesizes an any out of nowhere...
I'll open a PR after 5.5. I tried locally and there are several places that now have errors, but in my opinion they are all good. Maybe we have just a carveout if someone is not using noImplicitAny (although hopefully nobody is actually doing that π )
I think this is the same issue I'm having, but I'm not sure.
Problem description within...
// Exported from `@mylib/dev/jrfs`:exportinterfaceFileOf<D=unknown,M=unknown>{data: D;meta: M;}exporttypeFileTypes<FT>=Record<keyofFT&string,FileOf>;// Exported from `@mylib/dev/features/db`:exportinterfaceDbDesign{db: DbModel;}exportinterfaceDbDesignFileMeta{test: boolean;}exporttypeDbDesignFile=FileOf<DbDesign,DbDesignFileMeta>;
In the app project which imports from @mylib, when I use the DbDesignFile type exported from @mylib/dev, then VS Code shows the wrong type (const data: FileOf<DbDesign, DbDesignFileMeta>) in the tooltip and autocomplete doesn't work and it acts like the found data is any...
import{DbDesignFile}from"@mylib/dev/features/db";interfaceProjectFileTypes{db: DbDesignFile;}// Try it out:classYada<FTextendsFileTypes<FT>>{asyncfindTypes<KextendskeyofFT&string>(type: K,): Promise<Array<{node: any;data: Required<FT[K]>["data"];}>>{return[];}}constyada=newYada<ProjectFileTypes>();constnodes=awaityada.findTypes("db");for(const{ node, data }ofnodes){// TODO: Figure out why `data` is treated like `any` here:console.log("FOUND",node.name,data);}
However, if I re-define the DbDesignFile type alias in my app project then data from the yada.findTypes call above correctly shows and autocompletes type DbDesign...
UPDATE: I figured out my own issue - my library's type declarations were being created with import type {...} from "@/jrfs"; because I don't have anything in place to fix tsc created alias import paths. Once I changed those to use relative import paths it worked. So, never mind, sorry for the noise!
π Search Terms
declarations recursive types
π Version & Regression Information
β― Playground Link
Playground Link
π» Code
π Actual behavior
In declarations, the type for
a
is printed asa: () => T extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? V extends (infer V)[] ? any : V : V : V : V : V : V : V : V : V : V : T;
π Expected behavior
Recursive
can't be represented without falling back toany
(as seen above) so it should just be an error instead of silently toany
Additional information about the issue
Related to #55832
The text was updated successfully, but these errors were encountered: