This repository has been archived by the owner on Mar 20, 2022. It is now read-only.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably want entities to be something like
{ [key:string]: { [key:string]: E } }
since it's guaranteed to be nested with stringThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See this example, the entities are not the same
You prefer to type this, like this
And then
NormalizedSchema<Entities>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see how that would be more specific if you put the work in. For my cases I was happy with 'any' for the final result and really wanted to have the typings of the nesting level.
For me there's no way to know all the entity types statically, so this is unfeasible for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I let the default
any
value so you can use it like you do.But this can't be use with the no-unsafe-any rule from tslint.
It's not about typescript checking the type of the entity. It about typescript checking the use of the entity after you normalized them.
With the less precise typing you ask, we will have
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this makes sense, the typing should be on the entity. also @ntucker you can opt out by using any.