-
-
Notifications
You must be signed in to change notification settings - Fork 264
Closed
Labels
bug 🔥Something isn't workingSomething isn't workingjavascriptPull requests that update Javascript codePull requests that update Javascript code
Description
Description
After v0.86, PluginInstance.forEach is typed incorrectly. This is what the generated type before:
forEach<T extends IrTopLevelKind = IrTopLevelKind>(...args: [...events: ReadonlyArray<T>, callback: (event: WalkEvent<T>) => void]): and this is what we have now (note the T$1):
forEach<T extends IrTopLevelKind = IrTopLevelKind>(...args: [...events: ReadonlyArray<T$1>, callback: (event: WalkEvent<T$1>) => void]): Reproducible example or configuration
You can find the live minimal example here.
import type { DefinePlugin } from '@hey-api/openapi-ts';
type MyPluginConfig = { readonly name: 'myplugin' };
type MyConfig = DefinePlugin<MyPluginConfig>;
export const handler: MyConfig['Handler'] = ({ plugin }) => {
plugin.forEach('schema', 'operation', (event) => {
console.log(event);
});
};will produce the type checking error:
No overload matches this call.
Argument of type '[string, string, (event: never) => void]' is not assignable to parameter of type '[...events: Types<MyPluginConfig, MyPluginConfig, never>[], callback: (event: never) => void]'.
Type at positions 0 through 1 in source is not compatible with type at position 0 in target.
Type 'string' is not assignable to type 'Types<MyPluginConfig, MyPluginConfig, never>'.
Type 'string' is not assignable to type '{ config: MyPluginConfig; resolvedConfig: MyPluginConfig; }'.
Argument of type '[string, string, (event: never) => void]' is not assignable to parameter of type '[...events: Types<MyPluginConfig, MyPluginConfig, never>[], callback: (event: never) => void, options: WalkOptions<Types<MyPluginConfig, MyPluginConfig, never>>]'.
Type at position 0 in source is not compatible with type at position 0 in target.
Type 'string' is not assignable to type 'Types<MyPluginConfig, MyPluginConfig, never>'.(2769)OpenAPI specification (optional)
No response
System information (optional)
No response
Copilot
Metadata
Metadata
Assignees
Labels
bug 🔥Something isn't workingSomething isn't workingjavascriptPull requests that update Javascript codePull requests that update Javascript code