require - config

Topics: General
Jan 7, 2014 at 7:54 PM
I am building a web application in which the development isn't built on TypeScript, however the application has integration point which I want to do with plugin style - and this is where TypeScript is used. the TypeScript code is in second solution where I copy the js files to a folder in the first solution. I am using require to load everything. I have a problem of the path of the files in TypeScript. I have created require config
require.config({
paths: {
    VideoProviderCommon: 'Scripts/VideoProvider/VideoProviderCommon',
    VideoProviderManagerFactory: 'Scripts/VideoProvider/VideoProviderManagerFactory',
    VideoProviderManager: 'Scripts/VideoProvider/VideoProviderManager'
},
shim: {
    'VideoProviderCommon': { 'exports': 'VideoProviderCommon' },
    'VideoProviderManagerFactory': { 'exports': 'VideoProviderManagerFactory' },
    'VideoProviderManager': { 'exports': 'VideoProviderManager' }
}
});

and I want that the js files will have in the define - the module name as configured and not the path, how ever I cannot compile the TypeScript project cause I get compile errors
in
import common = require("VideoProviderCommon");
for example - as it cannot find the module although I have require config
Coordinator
Jan 8, 2014 at 4:29 PM
The TypeScript compiler doesn't currently support reading a require config, so you would need to provide the information to the compiler another way.

One way to do this would be to declare your external modules. For example, declaring "VideoProviderCommon" above:
declare module "VideoProviderCommon" {
    // module contents
}
You may be able to generate these based on what you're loading. Some of the people on the forums may have done something similar when using require config.