Open aneilbaboo opened 4 years ago
Aha - I just noticed that this happens when there's an existing index.guard.ts
file. Deleting the guard file and re-running ts-auto-guard results in the correct code being generated:
export function isRecursiveType(obj: any, _argumentName?: string): obj is RecursiveType {
return (
typeof obj === "object" &&
Array.isArray(obj.children) &&
obj.children.every((e: any) =>
isRecursiveType(e) as boolean
)
)
}
export function isParentType(obj: any, _argumentName?: string): obj is ParentType {
return (
typeof obj === "object" &&
obj.type === "parent" &&
Array.isArray(obj.children) &&
obj.children.every((e: any) =>
isChildType(e) as boolean
)
)
}
export function isChildType(obj: any, _argumentName?: string): obj is ChildType {
return (
typeof obj === "object" &&
obj.type === "child" &&
isParentType(obj.parent) as boolean
)
}
EDIT: Updated the title to reflect this.
Woah, that's mystifying... I've just invited you to be a collaborator if you're interested as I am not actively working on this project.
@rhys-vdw, cool - can't promise I will have results, but if I have some time, I'll take a look.
All good, no expectation. Just gave the role in case you need to fix anything or I'm taking too long to merge something.
Thx
I noticed that the typeguards for these recursive types don't perform a useful test:
index.ts
:index.guard.ts
: