14

I have an Angular 1.4 application that was written using an earlier version of Typescript. Now I am looking to update this to use the new module capabilities that Typescript 1.5 gives me.

Does anyone have any examples of how I can implement modules with the new Typescript and current AngularJS. I have seen examples that don't use Typescript but have yet to find any example that uses Typescript that is for Angular 1.4

5
  • Do you mean Typescript modules, Angular modules, or both? Commented Aug 3, 2015 at 10:29
  • @Sander_P - I'm sorry but I am not sure. All I know is I would like to do it in the way that makes the most sense now that we have Typescript 1.5 available. So far I have not been able to find any examples and judging from the upvotes to the question I think this is a topic that would be of interest to many people. Commented Aug 3, 2015 at 14:05
  • That's why I also upvoted it :) Commented Aug 3, 2015 at 16:02
  • Have you looked at John Papa's repository: github.com/johnpapa/hottowel-angular-typescript/tree/master/src/… Commented Aug 3, 2015 at 21:25
  • 1
    This question is currently being discussed here: meta.stackoverflow.com/q/302196/400654 Commented Aug 10, 2015 at 20:22

1 Answer 1

11
+200

Typescript 1.5 supports ES6 module syntax which are de-facto standard as of now because of the ES6 being officialy released as ES2015. Typescript 1.5 rebranded internal / external modules into namespace and modules and you should be doing it using modules. I have a github repository, where I am using this module import export syntax (without typescript but that doesn't matter because module import export syntax is the same). This example project was heavily inspired by reading this tutorial.

Generally speaking you also want to use some build tool (I recommend Webpack). Then you can take the code described in the links above and start adding types and interfaces and using TS classes instead of ES6 classes.

Edit: also you should use DefinitelyTyped repository for Angular JS declaration file

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

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.