In the script copyTypes.js, you should replace
...
const modifiedContent = content.replace('@strapi/strapi', '@strapi/types');
...
with
...
const modifiedContent = content.replaceAll('@strapi/strapi', '@strapi/types');
...
otherwise only the first occurance is replaced and the defined ContentTypes interface (defined at the very bottom of the generated contentTypes.d.ts) will still extend @strapi/strapi instead of @strapi/types.
Since we only have a dev dependency on @strapi/types in the frontend app, we won't be able to use proper typing when using the the generated schema types with Strapi's Data namespace, e.g. when referring to known custom entities using the type Data.ContentType<'api::my-collection.my-collection'> as described here in the Strapi docs, since the interface extension is not available when importing the Data class from @strapi/types.
With this adjustmend, I was also successfully able to use the generated types in my Vike frontend app using Strapi v5 in Backend.
In the script
copyTypes.js, you should replacewith
otherwise only the first occurance is replaced and the defined
ContentTypesinterface (defined at the very bottom of the generatedcontentTypes.d.ts) will still extend@strapi/strapiinstead of@strapi/types.Since we only have a dev dependency on
@strapi/typesin the frontend app, we won't be able to use proper typing when using the the generated schema types with Strapi'sDatanamespace, e.g. when referring to known custom entities using the typeData.ContentType<'api::my-collection.my-collection'>as described here in the Strapi docs, since the interface extension is not available when importing theDataclass from@strapi/types.With this adjustmend, I was also successfully able to use the generated types in my Vike frontend app using Strapi v5 in Backend.