Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angularjs definitely typed visual studio 2015

I'm trying to get my first angularjs project to work within Visual Studio 2015. Worked fine until I tried to move to Typescript. Installed the DefinitelyTyped projects and get lots of error messages.

Here is how to reproduce it:

  • Create an empty ASP.NET 4.5.2 application
  • Nuget AngularJS Core 1.4.4
  • Nuget AngularJS.TypeScript.DefinitelyTyped 4.1.1 (includes jQuery 0.0.1)
  • Add an empty TypeScript file
  • Add

    /// <reference path="typings/angularjs/angular.d.ts" />
    

    to that file.

  • that's when I get 444 errors, starting with

    Error   TS2411  Property 'find' of type '{ (selector: string): 
    IAugmentedJQuery; (element: any): IAugmentedJQuery; (obj: JQuery): 
    IAugment...' is not assignable to string index type 'HTMLElement'.  
    TypeScript Virtual Projects l:\M\eigene dateien\visual studio 
    2015\Projects\WebApplication3\WebApplication3\Scripts\typings
    \angularjs\angular.d.ts
    

Any idea what I'm doing wrong or how to work around it?

like image 691
Markus S Avatar asked Aug 19 '15 07:08

Markus S


1 Answers

I checked this package and most of the errors seem to come from the jquery.d.ts file, which just looks old. That file still uses "bool" instead of "boolean", which was a breaking change made long ago.

I fixed it by adding "jQuery.Typescript.DefinitelyTyped" to the project, which upgraded the jQuery.d.ts file to a version that parsed properly. As soon as I did that, all of the compiler errors went away.

This seems like a bug in the nuget package authoring. I'll look into opening an issue on github.

Hope that works for you.

UPDATE: I opened this issue in GitHub https://github.com/borisyankov/DefinitelyTyped/issues/5446

like image 128
Michael Braude Avatar answered Oct 19 '22 14:10

Michael Braude