Rage.MP - The Wonders of Importing Files in Typescript to Reference and Use

This subject really threw me a curveball. Nobody had a good answer for this other than webpack and javascript answers. Shame I'm using Typescript to write a majority of my client-side code.

Here's what I learned about importing files to use in other files in Typescript.

Here's the syntax I would put for pulling a file into my new file to use it:
import * MyOtherFile from "destination/path";

Here's how it looks in retrospect:
import * as MenuBuilder from "menubuilder/menubuilder";

The real question here is why... why didn't this work in the first place? Well. There can be all sorts of issues. I've found that not having your workspace starting from clientside_packages in Visual Studio Code can lead to all sorts of issues. Your solution is to just re-open your projects from clientside_packages and re-initialize your Typescript setup with tsc --init.

This is probably one of the larger solutions to the issues.

Then there is the tsconfig.json settings you may or may not need.

Add this to your tsconfig:
"baseUrl": "./",

That means it will sound the base of the folder as your root directory. Hence why menubuilder/menubuilder up there makes more sense when you look at my folder structure.

What did we learn? Setup a workspace properly. Configure your typescript correctly. When things don't work out, retrace your steps all the way back to the beginning.

Also for anyone who is curious. Wherever index.js is located is where Rage begins looking for scripts. So doing ../menubuilder/menubuilder from sandbox is not going to solve your issue. When it begins looking it'll look one step back from our currenct directory which is clientside_packages.

Hope this helps someone out there because this issue was quite torturous.