mancku / strapi-plugin-schemas-to-ts

Strapi Plugin Schemas to TS is a plugin for Strapi v4 that automatically converts your Strapi schemas into Typescript interfaces.
MIT License
62 stars 16 forks source link

using `destinationFolder` throws in non-typescript projects #56

Open nasheomirro opened 3 months ago

nasheomirro commented 3 months ago

I think the problem is on the validation of the config value, strapi.dirs.dist.root in javascript projects will be the same as strapi.dirs.app.root since javascript-based projects do not have a '/dist' folder, or at least that's what I'm assuming because no matter what valid value I'd give to destinationFolder, it will always give me this error:

Error: schemas-to-ts ⚠️  The given destinationFolder is inside the Strapi dist ...

modifying the src code a bit to log strapi.dirs inside dist/register.js and we get this:

{
  dist: {
    root: 'C:\\Users\\User\\Desktop\\projects\\my-project',
    // ...
  },
  app: {
    root: 'C:\\Users\\User\\Desktop\\projects\\my-project',
    // ...
  }
}

My current solution right now is to alter the value of strapi.dirs.dist.root inside the src code by adding a '//dist' string at the end.

Bredansky commented 2 months ago

It would be great to fix it ASAP :)

Bredansky commented 2 months ago

Okay, it's quite easy to update the JS project with TS changes. https://docs.strapi.io/dev-docs/typescript#add-typescript-support-to-an-existing-strapi-project

Now everything works like a charm