Closed Melchyore closed 5 months ago
Would something like that could work for you instead?
declare module '@vinejs/vine' {
type Group = ReturnType<typeof vine.group>;
interface MyModuleAugmentation {
foo(): string & Group
}
}
But maybe exporting these classes is ok. Naively I'm thinking that it would be exposing internals but maybe I'm wrong. @thetutlage will confirm
Yup, it works, but with a slightly different version. The type must be declared outside of the declare module
block.
type ObjectGroup = ReturnType<typeof vine.group>
declare module '@vinejs/vine' {
interface VineObject<Properties extends Record<string, SchemaTypes>, Output, CamelCaseOutput>
extends BaseType<Output, CamelCaseOutput> {
merge<Group extends ObjectGroup>(
group: Group
): VineObject<
Properties,
Output & Group[typeof symbols.OTYPE],
CamelCaseOutput & Group[typeof symbols.COTYPE]
> &
Group
}
}
Thank you!
❓ Type of change
📚 Description
Hey!
I'm working on a package to generate OpenAPI specs automatically based on the AST of AdonisJS apps. To do so, I need to augment the types of some VineJS methods (which is the case of the
merge
method of VineObject schema). But I couldn't do it, sinceGroupObject
andGroupConditional
are not exported to the userland.This is the current type of the
merge
method:And this is what I'm trying to achieve:
As you can see, I need the two classes to access to
Group
type.Is it possible to accept this PR, please?