Specific d.ts files and Amd modules with TypeScript

I import most of my DefinitelyTyped modules from https://github.com/borisyankov/DefinitelyTyped using nuget.

I am wondering if there is something that I missed because I find that they do not have AMD support.

In most modules, I add this myself:

declare module "toastr" { export = Toastr; } declare module "knockout.validation" { export = KnockoutValidationStatic; } declare module "knockoutmapping" { export = KnockoutMapping; } declare module "jquery" { export = $; } 

With this, I can do the following:

 import $ = require('jquery'); import toastr = require('toastr'); 

and it correctly creates my AMD modules.

 define(["require", "exports", 'toastr'], function(require, exports, __toastr__) { } 

I am wondering if there is another way to do this, since I found that the amd export defined in d.ts is missing for most libs.

+4
source share
1 answer

Some of the definitions have this section, for example. Underscore. The reason many of them are unrelated is because the import name depends on how you configure requirejs and the short name of the path you choose in your configuration.

0
source

Source: https://habr.com/ru/post/1500044/


All Articles