jmp909 Posted October 1, 2015 Share Posted October 1, 2015 Hi, I'm trying to use rStats.js in TypeScript/Visual Studio Code but of course with no .d.ts file it's throwing errors the issue is this is a constructorthis.rS = new rStats({ ... })but this is essentially a methodthis.rS('FPS').frame();I was going to use a basic empy definition but I can't use rStats for both the module name and the class constructor.. not really sure how to implement it thanks for any help.J (I can add this function rStats(obj:any):void {} , so it compiles at least.. and then make sure I embed rStats.js after game.js in my html file but that's a bit of a hack) Link to comment Share on other sites More sharing options...
jmp909 Posted October 1, 2015 Author Share Posted October 1, 2015 I find tsc in VS Code is temperamental, sometimes it gives errors about not being able to find Classes and sometimes it doesn't anyway this is currently working for me in my game class rS: anyrStats: any;but i need a file to exist even though i dont include a /// <reference ..> to it. rStats.d.tsdeclare class rStats { constructor(obj:any)}otherwise it seems to moan about calling new rStats({ ... })saying that it can't find rStats :S Link to comment Share on other sites More sharing options...
clark Posted October 1, 2015 Share Posted October 1, 2015 I have to say that I am totally confused by that Syntax.... `this.rs("FPS").frame()`. In JavaScript I do not know what is happening! So `let myStats = new rStats()` appears to return a function?? Then you call `myStats("property")` to return a value based on that property??? I am so confused! Why did the author not just use getters/setters or even just properties? I am sure there is a reason! Anyway!A cheap definition file could look like this to get rid of your error. rStats.d.ts`declare var rStats: any;` I was has hoping to throw a definition file together for you, but I just cannot understand what the code is doing jmp909 1 Link to comment Share on other sites More sharing options...
jmp909 Posted October 1, 2015 Author Share Posted October 1, 2015 Indeed! Here's the website by the wayhttp://spite.github.io/rstats/I think I tried a definition like that but them the rS() code didn't work, hence defining them both as any in the class using it ... I'll take another lookThanksJps spent ages last night trying to allow game.iso to work for the isometric plugin then just found this and realised I had an out of date version! :S http://www.html5gamedevs.com/topic/8387-phaser-isometric-plugin/?p=56922 . Thanks again Link to comment Share on other sites More sharing options...
jmp909 Posted October 1, 2015 Author Share Posted October 1, 2015 your method works thanks, i just need to define rS: any;in my code I'm going to try Visual Studio 2015 Community. Visual Studio Code seems a bit buggy although that could just be the tsc compiler the path messes up occasionally. I'm referencing some 'typings' outside of my project folder and it doesn't like it sometimes (see screenshot)<reference path="F:/typings/phaser/phaser.d.ts" /> Link to comment Share on other sites More sharing options...
chg Posted October 1, 2015 Share Posted October 1, 2015 I'm going to try Visual Studio 2015 Community. Visual Studio Code seems a bit buggy although that could just be the tsc compiler the path messes up occasionally. I'm referencing some 'typings' outside of my project folder and it doesn't like it sometimes (see screenshot) <reference path="F:/typings/phaser/phaser.d.ts" />Any chance you are using an old version of tsc? a year ago it only handled relative paths https://github.com/Microsoft/TypeScript/issues/800 *it looks like you should probably try and use a relative path though (eg. so you can more easily move your project folder later) Link to comment Share on other sites More sharing options...
jmp909 Posted October 1, 2015 Author Share Posted October 1, 2015 only installed TypeScript recently (1.6?) so I assume it should be new I was trying to keep the main generic typings out of the project root.. I could create a hardlink though. thanksj Link to comment Share on other sites More sharing options...
Recommended Posts