Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the "right" way of getting DefinitelyTyped typescript definition files in a .net core project?

Under asp.net for .net framework, I used to use nuget to import typescript type definitions 3rd party libraries. (*.d.ts) These packages are from DefinitelyTyped. I understand in the new world of .net core, nuget is no longer intended to be used for non-.net assemblies.

So is there a good way of getting typescript definitions into an mvc project? Right now, I'm going to the github repo, and downloading the ones I need manually using a web browser. There has to be a better way.

like image 571
recursive Avatar asked Aug 19 '16 22:08

recursive


1 Answers

Are you using TypeScript 2.0? If so, try to follow the instructions here: http://www.typescriptlang.org/docs/handbook/declaration-files/consumption.html. Basically there are "special" npm packages you can install with the types.

If you're not using TypeScript 2.0, are you using Gulp to compile your TS code? If so, you can simply do:

var typings = require("gulp-typings");
gulp.task("typings", function ()
{
    return gulp.src("./typings.json")
        .pipe(typings());
});

This will put all the typings you specify in your typings.json file into a /typings folder.

If you're using grunt instead there is a grunt-typings npm package and I'm sure you can find similar packages for other build runners as well.

like image 117
David Federman Avatar answered Oct 06 '22 00:10

David Federman