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

Migrating to stricter TypeScript #285

Open
5 of 8 tasks
abiyasa opened this issue Nov 15, 2023 · 1 comment
Open
5 of 8 tasks

Migrating to stricter TypeScript #285

abiyasa opened this issue Nov 15, 2023 · 1 comment
Assignees
Labels
blocked Blocked by external dependency or problem enhancement New feature or request tech debt The update/fix/change is overdue

Comments

@abiyasa
Copy link
Member

abiyasa commented Nov 15, 2023

Problems

Currently, we are compiling UI Core React without strict mode

"strict": false,

This means we will not get compilation error on many things when building ui-core-react. However, this might cause problems when the project that consumes ui-core-react use strict mode.

Solution

We need to enable strict mode on our TypeScript. However, this would cause 250+ compilation errors (v5.6.2) if we just set strict: true on tsconfig.

Therefore we need to incrementally enable strict mode and fix them gradually.

Options for Incremental Migration to TypeScript Strict Mode

Generally, one need to:

  1. (optional) maybe upgrade to TypeScript 4.6 or even 5? Currently, we're stil using v3.9 which is from 2020.
  2. Enable strict mode strict: true on tsconfig, which actually enabling at least 5 strict mode family options
  3. Add all strict mode family options and disable them all.
  4. Enable one of the strict mode family rule/option.
  5. Fix all errors related to the enabled rule.
  6. Create PR, merged, and release
  7. Repeat step 4.

See details on this article: https://www.bitovi.com/blog/how-to-incrementally-migrate-an-angular-project-to-typescript-strict-mode

Other techniques:

Plan by Tim:

Step 1

  • strictBindCallApply
  • useUnknownInCatchVariables
  • noImplicitThis
  • alwaysStrict

Step 2

  • strictFunctionTypes 21 errors

Step 3

  • strictNullChecks 150+ errors
  • strictPropertyInitialization requires strictNullChecks

Step 4

  • noImplicitAny 300+ errors
darkwebdev added a commit that referenced this issue Nov 16, 2023
* [#286] Upgrade to TS4, fix type errors

* [#285] TS: strict:true, noImplicitThis: true

* [#285] TS: strictBindCallApply: true, useUnknownInCatchVariables: true

* [#285] Improve debounce() readability
@darkwebdev darkwebdev self-assigned this Nov 16, 2023
@darkwebdev darkwebdev added enhancement New feature or request tech debt The update/fix/change is overdue labels Nov 16, 2023
darkwebdev added a commit that referenced this issue Nov 16, 2023
darkwebdev added a commit that referenced this issue Nov 16, 2023
darkwebdev added a commit that referenced this issue Dec 21, 2023
HenriqueLimas pushed a commit that referenced this issue Dec 21, 2023
* [#285] strictFunctionTypes:true, fix 9 errors

* [#285] fix 10 errors

* [#285] fix 12 errors

* [#285] strictFunctionTypes: true, fix 21 errors

* [#285] add more types instead of `any`

* fix type errors
@darkwebdev darkwebdev added the blocked Blocked by external dependency or problem label Jan 10, 2024
@darkwebdev
Copy link
Collaborator

Development blocked by the weird bug where icon is rendered two times, but not in dev environment. hard to reproduce and debug...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Blocked by external dependency or problem enhancement New feature or request tech debt The update/fix/change is overdue
Projects
None yet
Development

No branches or pull requests

2 participants