Typescript: Extend exported function, add parameter, use both

35 Views Asked by At

I am working with TypeSpec and would like to extend a decorator to have an extra property with custom implementation:

https://typespec.io/docs/extending-typespec/create-decorators#implement-the-decorator-in-js

export function $minLength(context, target, minLength) {
     //existing implementation
}

I would like to extend existing exported function to include one more parameter:

export function $minLength(context, target, minLength, profile) {
     //new implementation
}

End result: I can call either of the functions:

@minLength(1)
@minLength(1, "profile")

Happy path: no collision on import, no custom namespaces.

0

There are 0 best solutions below