royibernthal Posted June 27, 2016 Share Posted June 27, 2016 I'm using Visual Studio Code to edit TypeScript. 1) BABYLON is marked as an error: [ts] cannot find name 'BABYLON' Is it possible to import it somehow so that it'll be recognized? Preferably without having to compile the whole BABYLON framework from typescript to javascript on every compile just for that, unless doing so is trivial and doesn't take much time. 2) Is it possible to extend the framework's classes? e.g. how would I go about extending BABYLON's box (created by BABYLON.Mesh.CreateBox) using Typescript classes? Would something like that be in the right direction? class Box extends BABYLON.MeshBuilder.CreateBox Looks like extending a factory function rather than the box entity returned by it. 3) I'd like each of my classes to be written in a separate .ts file, is that possible? How would I then import / reference them in other .ts files? 4) I'd like to group my classes in packages, hopefully by simply creating folders for packages. Is that Possible? Are modules an alternative to packages in TypeScript? 5) In tsconfig.json, is there a way to specify something like "inDir" (like you can specify "outDir") instead of listing every single .ts file in "files"? Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted June 27, 2016 Share Posted June 27, 2016 1) You will need to have the Babylon.d.ts file defined in your project, possible as a source file. I am not familiar where VS wants it. 2) yes, but CreateBox is not a class. Not for this example. 3) From Eclipse yes, VS unknown. 4) Packages & package level access do not exist, since JS does not have them. Only Modules exist, No folder module relationship exists. 5)??? Quote Link to comment Share on other sites More sharing options...
royibernthal Posted June 27, 2016 Author Share Posted June 27, 2016 1) The following line references it. /// <reference path="lib/babylon.d.ts"/> But it'd be great if there was a way to automatically reference it in all .ts files in a project. 5) https://www.typescriptlang.org/docs/handbook/tsconfig-json.html Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted June 27, 2016 Share Posted June 27, 2016 There has got to be a better way to handle a d.ts file. Also related, you need to find the Visual Studio documentation for Typescript. That tsconfig seems like would be made by your IDE, not you. I use the Planatir plug-in for Eclipse. It front-ends that Typescript Node "module". I can specify multiple directories, single/ multiple js files. I just put the d.ts file in a source directory. VS cannot be much different. Quote Link to comment Share on other sites More sharing options...
Dal Posted June 27, 2016 Share Posted June 27, 2016 If you have a tsconfig file you shouldn't need to have references in every file.. if it sees that file is present it should by default compile all .ts files below that path, or you can use the "files" attribute in the tsconfig to list specific files, or "exclude" specific files. Quote Link to comment Share on other sites More sharing options...
royibernthal Posted June 27, 2016 Author Share Posted June 27, 2016 @JCPalmer Actually I created tsconfig.json manually, I didn't see any option in vs code to generate such a file, it may be because vs code is a lightweight version of vs, otherwise I just can't seem to find it. As far as I understand this file should be created manually, at least in vs code: https://code.visualstudio.com/Docs/languages/typescript Perhaps such options exist in vs code in one way or another, if so, they're not easily found, not by me at least. I invite you to download it and see for yourself if you feel like it It's around 20-30 MB from what I remember, clean and quick install. @Dal Does it recursively find all sub-directories as well? If not, how can I solve this? (I want to store different modules in different directories) Quote Link to comment Share on other sites More sharing options...
royibernthal Posted June 28, 2016 Author Share Posted June 28, 2016 Does anyone in this forum use Visual Studio Code and can give more educated answers on the subject? Otherwise, is there a different forum I should be asking this in? Quote Link to comment Share on other sites More sharing options...
Leemado Posted July 1, 2016 Share Posted July 1, 2016 On 6/27/2016 at 6:38 PM, royibernthal said: @JCPalmer Actually I created tsconfig.json manually, I didn't see any option in vs code to generate such a file, it may be because vs code is a lightweight version of vs, otherwise I just can't seem to find it. As far as I understand this file should be created manually, at least in vs code: https://code.visualstudio.com/Docs/languages/typescript Perhaps such options exist in vs code in one way or another, if so, they're not easily found, not by me at least. I invite you to download it and see for yourself if you feel like it It's around 20-30 MB from what I remember, clean and quick install. @Dal Does it recursively find all sub-directories as well? If not, how can I solve this? (I want to store different modules in different directories) You can automatically create the tsconfig.json file with command: tsc --init It does it recursively, or at list in my project i have my main.ts file inside a source dir and i execute tsc from the parent dir and it works Quote Link to comment Share on other sites More sharing options...
royibernthal Posted July 3, 2016 Author Share Posted July 3, 2016 @Leemado A little while after writing this question I tested it and it indeed does it recursively like you say, so that's good. Good to know about tsc --init. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.