0

I've decoupled my main.ts and place each class files into a separate .ts (under the same module). I want to use requirejs to include that module in my dependencies but I have no idea how to do that if the module is divided into multiple .ts/.js.

Thanks, Mars

2 Answers 2

2

Correct me if I am wrong but your question is about how to import a module that is split across multiple files...

My recommendation in terms of loading these modules is that you create a hierarchy to make the module more like a namespace. Here is an example...

Originally you have Logging as a single module. You then split it into multiple files for different flavours of logging. Use the following structure:

/Logging/Console.ts
/Logging/File.ts
/Logging/Remote.ts

You can then import what you need using:

import consoleLogging = module('/Logging/Console');

Or

import fileLogging = module('/Logging/File');

And so on.

Sign up to request clarification or add additional context in comments.

Comments

1

I have a video tutorial on that : http://www.youtube.com/watch?v=4AGQpv0MKsA

Basically to reference other ts files from your ts files you simply import them:

import otherfile = module('pathtootherfile')

The generated JS (when using the --module amd flag) does the setup that requireJs demands. It gets more involved when you want to import other JS files and that's covered in the tutorial as well as this sample project : https://github.com/basarat/typescript-amd

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.