0

I am having these requireJs options defined:

require.config({
    baseUrl: '/js/',
    paths: {
        jquery: '/components/jquery/dist/jquery',
        foundation: '/components/foundation/js/foundation',
        fastclick: '/components/fastclick/lib/fastclick',
        angular: '/components/angular/angular',
        angularRoute: '/components/angular-route/angular-route',
        socketIO: '/components/socket.io-client/dist/socket.io'
    },

    shim: {
        'foundation': {
            deps: ['jquery', 'fastclick']
        },
        'angular': {'exports': 'angular'},
        'angularRoute': ['angular']
    },
    priority: [
        'angular'
    ]

});

these are working all fine, if i am using requireJs in the javascript syntax. Then the base url and all these nice shortcuts for external libraries work.

But I am asking you now if i can also use these shortcuts in the Typescript way. Because If i am saying: for instance in a file

import angular = require('angular');

it isnot importing the file. I am ofc compiling the source with the amd option.

Also can someone provide me links how to navigate through the project with these import statement. my folder structure for client-side code

this structure is what i am using for my current project. There I have a client (public) folder and if i want to access a js file for instance in the browser. I have to write: localhost/js/file.js Now when i am using requireJs in the js syntax I can easily write things like controllers/userController and it navigated to the right folder, but how do i have to navigate within my import/require? currently I have to use relative paths from the file i am using the import but that is not very wise

1 Answer 1

1

I did this to make it work :)

/// <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/…

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.