Replace generated Enum with already existing #1683
Replies: 1 comment
-
|
🎉 I figured it Dumping my solution for future generations 😅 pluginTs({
output: {
/**
* add all Enum imports here
* eslint will "fix" unused imports for all files
*/
banner: `import { DemoGroup } from '../constants/demo-group';`,
},
mapper: {
demo_group: factory.createPropertySignature(
undefined,
factory.createIdentifier('demo_group'),
undefined,
factory.createTypeReferenceNode(
ts.factory.createIdentifier('DemoGroup'),
),
),
},
})then add hooks: {
done: [
// run eslint with `--fix` here
],
},Same had to be done for faker mapper: {
demo_group: 'faker.helpers.enumValue(DemoGroup)',
}, output: {
path: './',
barrelType: false,
/**
* add all Enum imports here
* eslint will "fix" unused imports for all files
*/
banner: `import { DemoGroup } from '../constants/demo-group';`,
}, |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
in TS plugin I managed to replace generated enum with already existing:
this allows us to use generated faker data in tests where input expects enum
DemoGroupI'm currently struggling with two issue:
Technically it's possible to create import declaration but where to put it?
I figured how to add
ts-ignoreif this import is not possible but it's not a great solutionBeta Was this translation helpful? Give feedback.
All reactions