Importing custom classes using typescript

Do I have to make an entire module to load / import a class (or classes) into my project written in typescript or is there a shortcut?

I have a standard (per example on babylon for setting up a new es6 project) index.ts / .js as which holds my my main code body.

Right now I have a series of classes in a nodes.ts file which obviously compiles into a nodes.js file. These classes… make a series of different types of nodes!

How do I go about linking the nodes.js to index.js getting things to a point where I can do a simple var node1 = new uNode(); in typescript and have it reference correctly? I tried importing and requiring but I did not have much luck. I started reading up on making modules, but that seems overkill for a few classes and difficult to manage to flip between modules and the main development code to make small changes or additions. Before I go down playing with that route I wanted to make sure there was not a super obvious way of doing this more simply that I missed.

pinging @sebavan

I am not totally sure what you are trying to achieve :frowning: Could you share a code example ? this would probably help me a lot to better understand it

So, say I have a player class and I want to use it in my NPM based project… What is the correct way to import that class, which is in a separate .ts/js file from the main babylon initialization / world building create scene functionality?

Do I need to make an entirely new npm module just for that player class and keep flipping back and forth to edit that class, or is there a better way of importing that separate “player class” js file into my main game initialization file so its compiled into the by default main.js at compile time.

No you don’t have to create a new module. Take a look at this stackblitz example.

Basically, create your new .ts file, and make sure to export your new class. Then where-ever you want to use that, import that class via the file.

Yup exactly as @Devin_Wright each file is basically a module you can import from. The only difference is that you would use a relative path when the file/module you want to import from is part of your project and not a separate npm package.