Created
June 18, 2012 22:56
-
-
Save ccapndave/2951285 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class TypeTest { | |
| public static function main() { | |
| myFunc({}); | |
| myFunc({ a: "Hello" }); | |
| myFunc({ b: 1 }); | |
| myFunc({ another: "something" }); | |
| } | |
| private static function myFunc(o:Opts):Void { } | |
| } | |
| // If I use this I get an error when using { another: "something" } | |
| typedef Opts = { | |
| @:optional var a:String; | |
| @:optional var b:Int; | |
| }; | |
| // If I use this I get '{ } should be Opts' | |
| class Opts implements Dynamic { | |
| var a:String; | |
| var b:Int; | |
| } | |
| // Ideally I want this, but its not allowed ('cannot only extend classes and anonymous') | |
| typedef Opts = { | |
| > Dynamic, | |
| @:optional var a:String; | |
| @:optional var b:Int; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment