System Information
- Strapi Version: ^4.11
Personally I’m new to Strapi and I was trying it out today with TypeScript. One of the first things I noticed was the TypeScript support seemed questionable/concerning:
- tsconfig.json seems to extend
@strapi/typescript-utils/tsconfigs/server
which looks like this
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"module": "CommonJS",
"moduleResolution": "Node",
"lib": ["ES2020"],
"target": "ES2019",
"strict": false,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"incremental": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"noEmitOnError": true
}
}
It strikes me as odd that a brand new TypeScript project would not have the “strict” option turned on. The only reason I could expect this option to be turned off is if this was a legacy project that is working towards being compatible with the “strict” option. Furthermore overwriting this option to turn strict on seems to produce errors because some of the code like the config
directory is not compatible with strict mode. In my opinion not having this option turned on defeats many of the benefits of TypeScript.
- Speaking of the
config
directory, why would these be TypeScript files if they don’t enforce any type? i.e. the admin.ts file is defined as this:
export default ({ env }) => ({
auth: {
secret: env('ADMIN_JWT_SECRET')
},
apiToken: {
salt: env('API_TOKEN_SALT')
},
transfer: {
token: {
salt: env('TRANSFER_TOKEN_SALT')
}
}
})
I don’t see any benefit in this being a TypeScript file. It doesn’t help you define what the object being returned should look like and it doesn’t define what type env
is so its treated as the any
type.
I haven’t looked through the other directories since this was enough to make me think Strapi doesn’t have very good TypeScript support at the moment. Is this sentiment you guys (the community) also feel is true? As of right now I’m thinking of creating a new project without TypeScript because dealing with half baked TypeScript support feels like its going to be a headache.