Making typedef fields optional

121 views
Skip to first unread message

Philippe Elsass

unread,
Jan 12, 2017, 1:11:25 PM1/12/17
to Haxe
Hello,

We have (and to keep) a structure using a typedef in a way that fields can be mandatory.

However in some cases we want to use a typedef with the same fields all optional as a function argument.

We can define the argument using a wrapper type like instance as OptionalFields<MyTypedef>.

Any suggestion?

Philippe

Dan Korostelev

unread,
Jan 12, 2017, 1:18:12 PM1/12/17
to Haxe
Should be easily doable with a @:genericBuild macro.

четверг, 12 января 2017 г., 21:11:25 UTC+3 пользователь Philippe Elsass написал:

Haxiomic

unread,
Jan 15, 2017, 5:19:20 PM1/15/17
to Haxe
This is quite a common situation, Typescript has made its 'Partial<T>' type part of the typescript standard library. As Dan said, @:genericBuild is the way, If anyone needs one, here's an implementation in haxe

Philippe Elsass

unread,
Jan 16, 2017, 3:23:14 PM1/16/17
to Haxe
Brilliant!

--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.



--
Philippe
Reply all
Reply to author
Forward
0 new messages