plopjs / plop

Consistency Made Simple
http://plopjs.com
MIT License
7.18k stars 280 forks source link

Bug: Can't use custom action in typescript plopfiles #439

Open maverox opened 6 months ago

maverox commented 6 months ago

In plopfile.ts whenever I try to use a plop-pack or a custom action, I get this error Screenshot 2024-05-27 032653

Now I figured that Actions is of type ActionType[] and ActionType is a union of various configs but when a custom type: "value" is found it narrows down to ActionConfig which doesnt have that property and hence it throws this error

awhitford commented 2 months ago

I am experiencing this too. I have a custom action that needs a custom parameter command and I get this TypeScript error during compilation:

plop/plopfile.ts:186:11 - error ts(2353): Object literal may only specify known properties, and 'command' does not exist in type '((answers: PromptProps) => string) | { type: string; path: string; pattern: RegExp; template: string; }'.

@crutchcorn @cspotcode

awhitford commented 2 months ago

I see an example like this in the tests: https://github.com/plopjs/plop/blob/202d00dcabb593632da7c9a2aa4f03ce66acff88/packages/node-plop/types/test.ts#L241-L254

Alas, I can't import CustomActionConfig:

'"plop"' has no exported member named 'CustomActionConfig'. Did you mean 'ActionConfig'?ts(2724)