Enums are not usable as values after updating from v2 to v3 #1743
-
I updated kubb from "2.10.0" to "3.10.12". I used with v2 the following kubb.config file for my type generation: import { defineConfig } from '@kubb/core';
import createSwagger from '@kubb/swagger';
import createSwaggerTS from '@kubb/swagger-ts';
const PATH = 'path';
export default defineConfig({
root: '.',
input: {
path: './src/api/swagger.json',
},
output: {
path: './src/api/generated',
},
plugins: [
createSwagger({
output: false,
}),
createSwaggerTS({
enumType: 'constEnum',
include: [{ type: 'path', pattern: FORM_PATH }],
}),
],
}); After the update I'm using import { defineConfig } from '@kubb/core';
import { pluginOas } from '@kubb/plugin-oas';
import { pluginTs } from '@kubb/plugin-ts';
const PATH = 'path';
export default defineConfig({
root: '.',
input: {
path: './src/api/swagger.json',
},
output: {
path: './src/api/generated',
extension: {
'.ts': '',
},
barrelType: 'all',
},
plugins: [
pluginOas({
generators: [],
}),
pluginTs({
enumType: 'constEnum',
include: [{ type: 'path', pattern: FORM_PATH }],
output: {
path: './types',
barrelType: 'all',
},
enumSuffix: '',
}),
],
}); Problem after updatingI noticed that all barrel files now use This causes TypeScript errors when using enums: export enum Status {
Active = 'active',
Inactive = 'inactive'
} If the barrel exports this file using export type *, any consumer code will throw:
Why this is a problem
WorkaroundI’m currently using a post-processing script to replace export type * with export *, but this feels like a hack and adds unnecessary build complexity. QuestionIs there a intended way to handle this problem? Is this an issue? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
@wnkchristopher I added the following issue so we could have a look on what is going wrong: #1749. This will probably be an easy fix. Thanks for using Kubb! |
Beta Was this translation helpful? Give feedback.
-
@wnkchristopher This will be resolved as part of Kubb v |
Beta Was this translation helpful? Give feedback.
-
Thanks @stijnvanhulle . Do you already know when v |
Beta Was this translation helpful? Give feedback.
@wnkchristopher This will be resolved as part of Kubb v
3.10.16