V4 released, but what about TypeScript?

Hi everyone,
I hope you’re well.

I’m currently working on multiple projects that are using Strapi, and the lack of typescript is a bottle-neck because of the waste of time it causes.

When we choosed strapi as our headless-cms, we saw that the Strapi team was considering to implement it. It was in early 2020.

We are soon in 2022, nothing have changed and it’s still “under consideration”. We’re considering to move somewhere else.

So what about it ?

Kind regards,

1 Like

There is already some typescript types throughout the code-base.

Further TS support will come in a few more months

1 Like

Could not agree more. TS is my number1 feature request and has been for years. Looking at the product board it has been a top requested feature, over 800, by the community for many years.

To add to the frustration there have been several attempts by other community members to create PRs to push progress but they often just go ignored.

2 Likes

I can not understand why you released Strapi v4 without Typescript. I mean, the Setup Process is not really hard and the quality of all developers would be so much better. You really should set more priority to Typescript.

Strapi is Amazing and with Typescript it would be so much more.

3 Likes

The problem is that the included typescript does not reflect what is really exported by the javascript code, so we get more errors than if nothing was made, I think it’s better to remove them.

Here are two articles from google how they migrated puppeter and the devtools with different approach:

I’ve managed to run Strapi v4 with TypeScript (app and plugins!) thanks to jiti package https://github.com/unjs/jiti which was originally made for nuxt3

I will try to make a template repository soon :wink:

2 Likes

I’ve made a PR:

You can test it with:

git clone git@github.com:stafyniaksacha/strapi-typescript-sample.git
cd strapi-typescript-sample
yarn
yarn develop # or yarn start
3 Likes

I got model types by installing strapi-to-typescript and then in src/importer.ts I replaced regex /.settings.json/ with /.json/ twice.

Otherwice it didnt work for v4.
Then I added command to package.json :

  "scripts": {
     ...
    "sts": "sts ./src -o ./sts"
  },

and after running it folder ./sts with types appeared.