Jump to content

TypeScript Questions


royibernthal
 Share

Recommended Posts

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"?

Link to comment
Share on other sites

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)???

Link to comment
Share on other sites

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.

Properties for QueuedInterpolation _218.png

Properties for QueuedInterpolation _219.png

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

@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)

Link to comment
Share on other sites

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 ;)

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...