goldensun_html5 icon indicating copy to clipboard operation
goldensun_html5 copied to clipboard

Set `strict` settings to `true` in `tsconfig.json`

Open MilesBHuff opened this issue 3 years ago • 6 comments

Setting strictMode to true in tsconfig.json would make entire classes of bugs impossible, including (but not limited to) #382, #392, and #393. https://github.com/jjppof/goldensun_html5/blob/master/tsconfig.json

MilesBHuff avatar Apr 11 '22 22:04 MilesBHuff

If you wait long-enough, I'll do this one for you. ;) Typing is a bit different than you're used to when this setting is enabled: null and undefined become completely separate types from string, number, etc -- so let foo: number = null becomes impossible. And that's a big part of how this avoids so many bugs.

MilesBHuff avatar Apr 11 '22 22:04 MilesBHuff

#382 was a logic problem because it was set with rare_item along with carry_up_to_30. I still need to write types for dbs and, in the best scenario, do some sanity checks...

And that's a big part of how this avoids so many bugs.

But yeah, for many other cases, I agree.

I'll do this one for you. ;)

Looking forward ☺

jjppof avatar Apr 11 '22 22:04 jjppof

Whoo boy, this is not something I'll be able to do 100% by myself, most-likely. Look how many errors there are when strict-mode is enabled: gshtml5_strictmode.log That's a grand total of 3069 errors.

MilesBHuff avatar Apr 12 '22 01:04 MilesBHuff

Okay, perhaps the best way to go about this, is to do it one setting at a time. First would be "noImplicitReturns". Then, we could go setting-by-setting within strict mode (strict mode is actually a collection of settings, rather than its own truly separate thing). And finally, the hardest one of all: "noImplicitAny".

MilesBHuff avatar Apr 12 '22 19:04 MilesBHuff

Sounds good. And yeah, maybe noImplicitAny can wait for a next release.

jjppof avatar Apr 13 '22 01:04 jjppof

The following have been enabled:

        "forceConsistentCasingInFileNames",
        "noImplicitReturns",
        "strictBindCallApply",
        "alwaysStrict",
        "useUnknownInCatchVariables",
        "noImplicitThis",
        "strict",

The following have not:

        "strictFunctionTypes",
        "strictNullChecks",
        "strictPropertyInitialization",
        "noImplicitAny",

(The above are all in the order they were enabled, or the order in which they will be enabled.)

MilesBHuff avatar Apr 17 '22 17:04 MilesBHuff