-
Notifications
You must be signed in to change notification settings - Fork 54
Am I doing it wrong? #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It appears that TypeScript (as of 1.6) is unhappy with additional properties being added to a class. An interface should ensure that certain members are always or optionally present, but the class definition should be able to add members. If you want to handle an object by interface, then you only get to access those members. If you do a widening cast to the class itself, then it should be able to type check the additional members. This is how it worked in the original ActionScript, and usually works elsewhere. Here is the issue thread on TypeScript project that discusses it: So, it appears that two approaches could be taken here:
|
Thank you for taking the time to look into this. That's disappointing. But since it is the way it is, I think I will go with the route that involves creating a VO and then using the onRegister override to instantiate it. Best Regards, |
Timothy, I wonder, while you are working with the TS port, if you could clone the Employee Admin repo https://github.com/PureMVC/puremvc-typescript-demo-employeeadmin.git and see if it has such problems going on when you use the latest TS. Because the proxies there, although they do use VOs, definitely have non-interface methods defined. If you don't have the time, I totally understand and I'll look into it myself shortly. |
I should have time this evening. |
After examining the employee admin demo, I found that using type casting resolved the indifference between the interface IProxy and the concrete class: var user:UserProxy = <UserProxy>this.facade().retrieveProxy(recypt.UserProxy.NAME); I have found a number of errors, though, due to changes in the Typescript language overtime. For instance, declaring a boolean used to be something like this: var result:bool = false; Today it's like this: var result:boolean = false; I also see code like this: var users:UserVO[] = new UserVO[](); Which should be changed to this: var users:UserVO[] = new Array<UserVO>(); There are also a number of issues with the Typescript Definitions files for jQuery, jQueryUI, and PureMVC-standard. Finally, Typescript does not need to make use of ANT and JDK to compile. You can now use the command (tsc -init) to create a configuration file which can then be configured to identify which files get included into the resulting Javascript file. After that's setup you can simply type 'tsc' to compile the Javascript. It currently won't successfully compile. Best Regards, |
Note that the 1.1 version of the PureMVC Multicore Typescript Definitions doesn't have any errors in it with the current version of Typescript. |
I've been spending a lot of time working with untyped JS. Fzzzz. Yes, the widening cast should generally be done when you fetch a Proxy or Mediator. The original actionscript for your fetch above was:
I see that in the existing typescript we're doing it like this:
|
And thanks for turning up that list of todos, which I'll condense here, along with my observations:
|
Thanks again. My application is coming together quite nicely. |
Great to heat it. Let us know when it's done. Maybe blog about your experience. Cheers, Sent from my iPhone
|
I've been using the Javascript implementation of PureMVC and recently decided to try the Typescript implementation.
I've created a UserProxy and registered it with the facade. The UserProxy looks like this:
But, when I retrieve the proxy from my controller:
I get the following type-checking error:
Am I not supposed to be tied down to the methods and properties in the interface? It seems very limiting for the model to be locked to these methods. I guess I can create a separate model class and use setData to instantiate it. Is that the intended approach?
The text was updated successfully, but these errors were encountered: