1

Currently I have 2 different ways in case I want to load in external code into my typescript file.

If i refer to another typescript file I have to write:

import object = require('./path/to/the/internal/module');

but if I am loading code from an existing js file, I have to do it like that:

/// <reference path="./types/angular/angular.d.ts" />
///<amd-dependency path="angular"/>
var angular:ng.IAngularStatic = require('angular');

is there no way to make these two things look the same? So that i can for instance do something like that:

/// <reference path="./types/angular/angular.d.ts" />
import angular = require('angular');

btw do you recommend me to load the external things like angular, jquery,... via requirejs or globally on its own script tag?

1 Answer 1

4

Just declare it as an external module

/// <reference path="./types/angular/angular.d.ts" />
declare module 'angular'{
    var angular:ng.IAngularStatic;
    export = angular;
}

// now you can do: 
import angular = require('angular');
Sign up to request clarification or add additional context in comments.

1 Comment

I did similar thing. You can see more detailed example here: stackoverflow.com/questions/18171045/…

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.