Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stricter TypeScript settings #88

Merged
merged 15 commits into from
Sep 9, 2021
Merged

Conversation

MrChocolatine
Copy link
Member

@MrChocolatine MrChocolatine commented Jun 4, 2021

Build

Enable TypeScript flag strict (#88)

Enforce a stronger TypeScript configuration by enabling all of the strict mode family options.

https://www.typescriptlang.org/tsconfig#strict :

The strict flag enables a wide range of type checking behaviour that results in stronger guarantees of program correctness. Turning this on is equivalent to enabling all of the strict mode family options

Enable TypeScript flag noEmitOnError (#88)

From the add-on ember-cli-typescript:

Set "noEmitOnError": true in the "compilerOptions" hash in your tsconfig.json – it will help a lot if you can be sure that for the parts of your app you have added types to are still correct. And you'll get nice feedback immediately when you have type errors that way!

A good way to ensure nothing is emitted if errors are still detected.

Enable TypeScript flag forceConsistentCasingInFileNames (#88)

A good safeguard to make the project even more bullet-proof.

https://www.typescriptlang.org/tsconfig#forceConsistentCasingInFileNames

TypeScript follows the case sensitivity rules of the file system it’s running on. This can be problematic if some developers are working in a case-sensitive file system and others aren’t. If a file attempts to import fileManager.ts by specifying ./FileManager.ts the file will be found in a case-insensitive file system, but not on a case-sensitive file system.

When this option is set, TypeScript will issue an error if a program tries to include a file by a casing different from the casing on disk

Enable TypeScript flag noImplicitOverride (#88)

https://www.typescriptlang.org/tsconfig#noImplicitOverride

When working with classes which use inheritance, it’s possible for a
sub-class to get “out of sync” with the functions it overloads when
they are renamed in the base class.
...
Using noImplicitOverride you can ensure that the sub-classes never
go out of sync, by ensuring that functions which override include the
keyword override.

Refactor

Disable redundant lint rules (#88)

Fix types definitions (#88)

Improve arguments of deprecation warnings (#88)

Test

Set more accurate types definitions (#88)

Remove logical expressions from assert (#88)

Remove unnecessary assert.expect() (#88)

@MrChocolatine MrChocolatine changed the title stricter typescript settings Stricter TypeScript settings Jun 4, 2021
@MrChocolatine MrChocolatine added this to the Path to version 2 milestone Jun 4, 2021
@MrChocolatine MrChocolatine force-pushed the stricter-typescript-settings branch 3 times, most recently from 21ac098 to f172dba Compare September 3, 2021 17:54
@MrChocolatine MrChocolatine marked this pull request as ready for review September 3, 2021 17:58
@MrChocolatine MrChocolatine requested a review from a team September 3, 2021 18:30
@MrChocolatine MrChocolatine force-pushed the stricter-typescript-settings branch 2 times, most recently from af68751 to bd5531e Compare September 6, 2021 11:19
@MrChocolatine MrChocolatine force-pushed the stricter-typescript-settings branch 5 times, most recently from b034356 to 2b6f625 Compare September 9, 2021 16:45
https://www.typescriptlang.org/tsconfig#strict

> Turning this on is equivalent to enabling all of the strict mode
> family options ...
https://www.typescriptlang.org/tsconfig#noEmitOnError

> Do not emit compiler output files like JavaScript source code,
> source-maps or declarations if any errors were reported.
https://www.typescriptlang.org/tsconfig#forceConsistentCasingInFileNames

> When this option is set, TypeScript will issue an error if a program
> tries to include a file by a casing different from the casing on disk
https://www.typescriptlang.org/tsconfig#noImplicitOverride

> When working with classes which use inheritance, it’s possible for a
> sub-class to get “out of sync” with the functions it overloads when
> they are renamed in the base class.
> ...
> Using `noImplicitOverride` you can ensure that the sub-classes never
> go out of sync, by ensuring that functions which override include the
> keyword `override`.
Why? When talking about "nullish values" we explicitly only refer to `null` and `undefined`:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator
1. This assertion is already included in another test.

2. Considering the title of the test "it defers the boot of the app",
   this assertion does not belong here.
@MrChocolatine MrChocolatine merged commit 1e6e320 into master Sep 9, 2021
@MrChocolatine MrChocolatine deleted the stricter-typescript-settings branch September 9, 2021 17:06
@MrChocolatine MrChocolatine mentioned this pull request Sep 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants