strapi-plugin-schemas-to-ts
strapi-plugin-schemas-to-ts copied to clipboard
destinationFolder property has unexpected behaviours
Types are not getting generated into specified folder.
schema-to-ts config ("^1.3.0"):
'schemas-to-ts': {
enabled: true,
logLevel: 0,
usePrettierIfAvailable: true,
destinationFolder: "src/types/strapi",
}
Result:
I am on windows os. strapi 4.20.4.
And the types are still getting generated under collections such as api/event/content-types/event/event.ts.
I dont know if this is intended or fallback behaviour but it is unexpected that the plugin does this when setting the destinationFolder.
Hi @gregg-cbs I introduced a bug on the components paths, but it should be fixed now. Please, update to 1.3.1 and tell me if you get the expected behavior
Now im getting "TypeError: Cannot read properties of undefined (reading 'needsComponentSuffix')"
More of the error: PostV414InterfaceBuilder.buildInterfaceText (D:\Devbox\cbs\my-project\server\node_modules\strapi-plugin-schemas-to-ts\dist\server\schemas-to-ts\interface-builders\interfaceBuilder.js:258:35
@gregg-cbs that's weird 🤔 That line is inside the block that builds the interface for the component, yet in converter.ts, inside the parseSchema method, there's this code:
let needsComponentSuffix = schemaSource === schemaSource_1.SchemaSource.Component &&
(this.config.alwaysAddComponentSuffix || apiSchemas?.some(x => x.pascalName === pascalName));
if (needsComponentSuffix) {
pascalName += 'Component';
}
This method is called for every file, so it should never be undefined for the components because apiSchemas should always have a value there. Can you provide more info about your schemas or the component that was being parsed when the exception happened?
@gregg-cbs shouldn't your config look like this?
"schemas-to-ts": {
enabled: true,
config: {
logLevel: 0,
usePrettierIfAvailable: true,
destinationFolder: "src/types/strapi",
}
},
I unfortunately ditched this plugin due to hurdles at the time. It was slowing down our dev server reloads because it was building types every reload + coupled with these issues i thought its best to leave it and come back to it at a later stage.
Thanks for the responses. I will try this again when I have some time :)
Will have a look at the repo in future since I’m using it constantly and will try to do my best to contribute. So I’d suggest to open a new issue with future request and I’ll try to look into them (: