-
Notifications
You must be signed in to change notification settings - Fork 130
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
Possible incompatibility of function.depends pattern with TypeScript #396
Comments
Hello, Thank you for your answers and for creating this issue, I did find a web site where I can create a working example in TypeScript! In this pen, I tried to explain the issue with my latest findings, it looks like it might be Visual Studio that is wrong. I can also provide files if useful for you. Regards, |
Thanks Claude. I will come back to this at some point, when I look more closely at TypeScript support for JsViews and JsRender. It's very helpful to have this example... |
Dear Boris, I am coming back to this project where the function .depends doesn't work for me in VS 2017 using TypeScript. Would you, by any chance, have some news that would bring light upon this issue ? Thanks and regards, |
Hi Claude, |
Hi Claude - I have finally completed work on V1.0 - to be published soon. I also have completed TypeScript declaration files for jsrender and jsviews: Note that jsviews.js includes the code from jsrender.js, jquery.observable.js and jquery.views.js. So no need to load jquery.observable.js in your codpen sample. (See https://www.jsviews.com/#download) Here is a fork of you codepen that includes the TypeScript declaration code, and fixes your issues. https://codepen.io/borismoore/pen/wQmPoz And here is another which tests loading jsrender and jsviews d.ts files from a server (you can replace with your own URLs): https://codepen.io/borismoore/pen/wQmXRB After publishing V1.0 I will publish the d.ts files to definitelyTyped.org. The fix for your sample was to move the setting of .depends to before calling tmpl.link: (this.GetName as JsViews.GetSet).depends = "~root.activeLanguage";
// Or (this.GetName as JsViews.GetSet).depends = [this, "activeLanguage"];
tmpl.link("#optionsTmpl", this); BTW the casting of Let me know if you see other issues (e.g. with the TypeScript definitions)... |
Closing this issue, since it is not a JsViews bug. (Also it seems to be fixed by the suggested cchange to your code). |
Dear Boris,
It has bring me so much joy when you answered me !!! Thanks a lot !! 🙂
It took me some time but I rewrote my game, using your solution and waited that it is a bit more advanced before showing it.
It is still far from done but here it is, if you would like to have a look:
https://unchartedwaters3.azurewebsites.net/
You land on the Atlantic sea near the town of Lorient in France.
The orange button on top-left corner opens the options where you can change language and navigate to other towns, kind of a cheat mode.
You can also click on the Lorient city. Shops gets highlighted when mouseover is triggered.
Clicking on the "Old' Shop" on the left side brings up the logic I did to enable users to buy products and using JSView, I update the cargo load, the amount of gold and the shopkeeper inventory with one click of the JQuery Slider !!!
There is still a lot of work but I'm very happy that I was able to build this screen !!
I hope that all is going well for you, thank you for JSViews and TypeScript extensions.
Kind regards,
Claude
…________________________________
De : Boris Moore <notifications@github.com>
Envoyé : vendredi 23 novembre 2018 07:39
À : BorisMoore/jsviews
Cc : ClaudeVernier; Comment
Objet : Re: [BorisMoore/jsviews] Possible incompatibility of function.depends pattern with TypeScript (#396)
Hi Claude - I have finally completed work on V1.0 - to be published soon. I also have completed TypeScript declaration files for jsrender and jsviews.
Note that jsviews.js includes the code from jsrender.js, jquery.observable.js and jquery.views.js. So no need to load jquery.observable.js in your codpen sample. (See https://www.jsviews.com/#download)
Here is a fork of you codepen that includes the TypeScript declaration code, and fixes your issues.
https://codepen.io/borismoore/pen/wQmPoz
And here is another which tests loading jsrender and jsviews d.ts files from a server (you can replace with your own URLs):
https://codepen.io/borismoore/pen/wQmXRB
After publishing V1.0 I will publish the d.ts files to definitelyTyped.org.
The fix for your sample was to move the setting of .depends to before calling tmpl.link:
(this.GetName as JsViews.GetSet).depends = "~root.activeLanguage";
// Or (this.GetName as JsViews.GetSet).depends = [this, "activeLanguage"];
tmpl.link("#optionsTmpl", this);
BTW the casting of this.GetName to as JsViews.GetSet is to avoid the TypeScript 'error'. But getting the error does not really matter since the compiled .js is still correct, and works just the same...
Let me know if you see other issues (e.g. with the TypeScript definitions)...
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<#396 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ADicLQc9crUr2LiUcprlWQnHOqyHIaE1ks5ux5gtgaJpZM4RTPQF>.
|
Thanks Claude, glad to hear back from you... |
Hi, I know this issue is closed but I found it while searching the same issue.
An then you can do something like this
The main advantage of this solution is to keep the function definition and its Here is the working codepen : https://codepen.io/jonathantisseau/pen/NWKRvOQ I'm new to JsViews so I haven't tested it in every possible ways. |
Thanks for the suggestion and code, @jonathantisseau! |
See https://stackoverflow.com/a/47859851/1054484.
The text was updated successfully, but these errors were encountered: