troyedwardsjr Posted February 13, 2018 Share Posted February 13, 2018 I've started writing a generator for Phaser 3 typescript definitions using Richard's JSDoc annotations. If anyone is interested in helping: https://github.com/troyedwardsjr/phaser3-tsd Link to comment Share on other sites More sharing options...
Antriel Posted February 14, 2018 Share Posted February 14, 2018 I already worked on this the past week, it's almost ready. Fenopiù 1 Link to comment Share on other sites More sharing options...
troyedwardsjr Posted February 15, 2018 Author Share Posted February 15, 2018 Making good progress on writing my Phaser 3 typescript definition generator/transpiler. First full build: https://github.com/troyedwardsjr/phaser3-tsd/blob/master/build/phaser.d.ts Link to comment Share on other sites More sharing options...
Antriel Posted February 16, 2018 Share Posted February 16, 2018 My WIP: Link to comment Share on other sites More sharing options...
troyedwardsjr Posted February 18, 2018 Author Share Posted February 18, 2018 I haven't tested everything yet but using my modified version of Antriel's official (WIP) Phaser 3 typescript definitions build, I was able to get scene properties (plugins) to work using a hacky generator by stepping through Phaser code with the browser debugger, converting any useful runtime data to JSON, writing it to disk, then converting it with a simple script, and injecting it into Antriel's build. End result: Everything appears to be compiling in the typescript compiler so far, with code hinting, autocompletion/intellisense, ect. in VS Code (and I imagine similar editors). Note: This is a temporary, hacky, potentially unstable solution for those who want to start building their Phaser 3 typescript projects right now while we wait on offical typescript support to be completed by Antriel and the Phaser team. Modified build here: https://github.com/troyedwardsjr/phaser3-tsd/blob/master/build/official/phaser.d.ts Also created a boilerplate starter project, with definitions included: https://github.com/troyedwardsjr/phaser3-typescript-webpack Sturmkrahe 1 Link to comment Share on other sites More sharing options...
Ppozniak Posted February 18, 2018 Share Posted February 18, 2018 Great! That's what I've been looking for, but can you use this without TypeScript in VSCode using IntelliSense? Link to comment Share on other sites More sharing options...
troyedwardsjr Posted February 18, 2018 Author Share Posted February 18, 2018 1 hour ago, Ppozniak said: Great! That's what I've been looking for, but can you use this without TypeScript in VSCode using IntelliSense? I believe so. One way I know of is copying the typescript definition file to the root of your phaser folder in node_modules, and changing the phaser package.json file to have the field "types" : "./phaser.d.ts" in it. Then either restart the TypeScript server in VS Code by pressing CTRL + SHIFT + P and searching "Restart TS Server" or just restarting VS Code. So as long as you're using NPM and RequireJS or ES6 Import, you should be able to use it with vanilla Javascript or ES6. https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html https://code.visualstudio.com/docs/languages/javascript Sturmkrahe and Ppozniak 2 Link to comment Share on other sites More sharing options...
Recommended Posts