-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3d4cb33
commit 4fcdba3
Showing
62 changed files
with
1,131 additions
and
991 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
4fcdba3
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.
EntityLine<T>
with TS 5.4 betaThis Commit, (and this) finish a change that I wanted to do for a long time: Give a really stronly typed API for all the components inhering from:
This change should not affect you most of the time so you can still write:
as usual, but when you want to use some of the events line
onView
orgetComponent
you get an strongly-typed lambda.The generic parameter should be inferred ONLY from the
ctx
attribute. This was not possible before the new TypeScript 5.4 (currently in Beta) that introduces the newNoInfer<T>
utility type.Correctly expressing the behaviour of all the components events is a little bit challenging, for example imagine this example:
if
customer
is aLite<CustomerEntity>
,onView
won't retrieve it azutomatically for you, but in your lambda you can return either aCustomerEntity
orLite<CustomerEntity
back to theEntityLine
and it will be converted authomatically.To express all this subtilities a few new typescript types are necessary:
All this utility types make extensive use of NoInfer, so that only
ctx
is used for the type inference.Finally, one thing to note is tha
EntityListBase
does not inherit fromEntityBase
anymore, instead it inherits directly fromLineBase
for simplicity.How to update:
Run the upgrade
Upgrade_20240215_GenericLines
. It will update to Typescrpt 5.4 beta and clean some code, likeEnjoy!
4fcdba3
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.
Superb💯