#strict TS partial

16 messages · Page 1 of 1 (latest)

lilac nexus
#

I want to partially turn strict on or something, I want to get my project to work under strict, though right now, it does not and if I turn it on I get [9:33:47 PM] Found 675 errors. Watching for file changes. which is a bit much lol.

 {
  "compilerOptions": {
    "target": "es2022",
    "moduleResolution": "Bundler",
    "module":"es2022",
    "strict": false,
    "esModuleInterop": true,
    "outDir": "./.dist",
    "removeComments": false
  },
  "include": [
    "./webpage/*.ts"
  ],
  "exclude": [
    "node_modules"
  ]
}

here's my current config

mighty flame
#

strict doesn't make any changes directly, rather it enables a bunch of subrules:

  • alwaysStrict
  • strictNullChecks
  • strictBindCallApply
  • strictFunctionTypes
  • strictPropertyInitialization
  • noImplicitAny
  • noImplicitThis
  • useUnknownInCatchVariables
    you can enable these one at a time to solve each kind of issue separately, then remove them and use strict afterwards
#

anyways even with type errors tsc can still emit js

lilac nexus
#

Yeah, though it's a lot of errors to deal with

#

When 675 errors spread across 25 files

#

thank you

hard sage
#

@lilac nexus Was your project JS originally?

lilac nexus
#

At one point, though it's been TS for a while now

hard sage
#

Ah. My suggestion for migration is to turn strict: true but to leave files as .js until you're ready to migrate them and address strictness issues.

lilac nexus
#

they're all .ts

hard sage
#

Yeah, probably too late for that strategy.

lilac nexus
#

All of the files have typings

#

And I have arround one error every 12 lines ish

hard sage
#

Yeah, not sure there's much better you can do other than just trying to turn the rules on one at a time.

#

Though strictNullChecks and noImplicitAny probably account for like 90% of them.

lilac nexus
#

Yeah