Typescript with config request

I am creating a web application in which the development is not built on TypeScript, however the application has an integration point that I want to make using the plugin style, and TypeScript is used here. TypeScript code is in the second solution, where I copy the js files to a folder in the first solution. I use everything to download. I have a problem with a file in TypeScript. I 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 the js files to have in the definition - the name of the module as configured, and not the path, as if I could not compile the TypeScript project, because I get compilation errors in

import common = require("VideoProviderCommon");

for example, since it cannot find the module, although I need config

define(["require", "exports"], function(require, exports) {
     .....
  var videoWorkItem = (function () {
    function videoWorkItem() {
    }
    return videoWorkItem;
})();
exports.videoWorkItem = videoWorkItem;

});

+4
source share
2 answers

typescript require.js:

<html lang="en">
<head>
    ...
    <script data-main="Scripts/main" src="Scripts/require.js"></script>
    <script src="Scripts/config.js"></script>
</head>
<body>...</body>
</html>

index.html

config.ts:

requirejs.config({
    baseUrl: "Scripts",
    paths: {
        jquery: "jquery-1.10.2"
    }
});

config.ts

jquery :

import $ = require("jquery");
$(() => {
    alert("Hello world!");
});

main.ts

. require, jquery .. NuGet

+1

JS typescript, . , :

declare module "VideoProviderCommon"{
    var foo:any;
    export = foo;
}

amd-dependency, : http://www.youtube.com/watch?v=4AGQpv0MKsA&hd=1

0

All Articles