chore: adds new strict rules for TypeScript #5644
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes LPS-190200
Well, this PR reduces the amount of TypeScript errors for environments with more restricted configurations, there are some rules that we cannot add due to errors in other libs that we use and others because it forces our code to be more redundant in an unnecessary way because they are configurations of taste and not something that really helps.
So we are not covering use cases here for:
exactOptionalPropertyTypes
- This seems to be more a property of personal taste than something that really helps with typing because it renders thename?: string
syntax useless to force typeundefined
in the whole optional property, this is something that makes it quite verbose too and breaks the build of internal dependencies that we couldn't change, for example the types for@types/react
and@types/react-dom
.noImplicitReturns
- Most of our cases are the return function inside a condition in unuseEffect
, always forcing the return for these use cases leaves our code too redundant to do property checks and add theuseEffect
clean up unnecessarily for use cases where we don't want it.In this ticket also seems to always happen a bug of
TS2786: 'Component' cannot be used as a JSX component.
this is normally caused due to version incompatibility, for example we use the dependency of the types of@types/react
and@types/react-dom
both in versionv16.9.9
due to the version we use and also to avoid conflicts with the portal. In this case, we recommend the team to try to normalize the type versions to maintain compatibility with the v16.x.x version.