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?
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
I had the same issue, but the above solution didn't work out for me.
jQuery.Typescript.DefinitelyTyped was already installed as it is required by angularjs.TypeScript.DefinetlyTyped package.
I fixed it by:
uninstall angularjs package.
uninstall angularjs.TypeScript.DefinetlyTyped package.
uninstall jQuery.Typescript.DefinitelyTyped
install jQuery.Typescript.DefinitelyTyped
install angularjs.TypeScript.DefinetlyTyped package.
install angularjs package.
Thanks Michael for supplying the hint.
The issue is caused by NuGet in VS 2015, because it defaults to installing the oldest version of its dependencies which in this case installs ancient jQuery DT package for the AngularJS DT package, as explained here.
I fixed this even simpler by just doing these:
Manage NuGet packages for project
Show only installed packages
Select jquery.TypeScript.DefinitelyTyped
Upgrade
Enjoy!
Related
I am working with asp.net core- Visual studio 2015.While accessing my sql database the following error occurs. "Please add the Entity.framework.SqlServerCompact NuGet package to the project". Please let me know how to resolve this issue. Thanks in advance.
Well with ASP.net Core everything is optional and as Nuget packages which means you have to bring them in your project if you want to use them.
If you want to add any Nuget package to your project you just need to open your project json file and add this line into dependencies:
Microsoft.EntityFrameworkCore.SqlServer
Or run npm install in your project directory:
Install-Package Microsoft.EntityFrameworkCore.SqlServer
Then locate your tools section in your project json and add this into it:
"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.0.0-preview3-final"
If you had any problem with the version see if using this version is helping:
"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.0.0-preview2-final"
Reason is this is a known issue you can find here:
https://github.com/dotnet/cli/issues/3742
Check the version in case has changed. For a more detailed instructions look here:
https://learn.microsoft.com/en-us/ef/core/get-started/aspnetcore/new-db
After updating the NuGet Type Scripts packages, I was facing with one common build error problem "tsc.exe exited with code 1". After searching I have found the solution how to resolve it. As suggested I installed another two NuGet packages named Microsoft.TypeScript.Compiler and Microsoft.TypeScript.MSBuild. After installing those the tsc.exe exited with code 1 problem solved. But in the mean time a new problem arise on build "Unknown compiler option 'listemittedfiles'".
I was trying to solve it by the suggestion of this Typescript build failure.
But still there has no improvement of this problem.
Can anyone be able to provide a solution please? Please take a lots of thanks in advance.
My client project structure is looks like the image Please click here to view the image
I suggest you to try to fix this issue by installing TypeScript 2.0.6 using the following link:
Visual Studio 2015 TypeScript Tools (2.0.6 at the time of writing)
This will also point MSBuild to the proper TypeScript build, which fully supports the --listEmittedFiles command switch.
See also this answer and/or this blog article I wrote on this topic for further details and references about this issue.
I had the some problem. I found out, that I had a wrong (i.e. older) version of typescript installed (in addition to the current one) and even though the latest version was installed too, the old typescript compiler (tsc) was used.
Open a windows console and run the command following command:
tsc -v
The result should be:
Version 1.0.1.0
If you have the latest typescript installed but don't see the version above, you probably have older versions of typescript installed, that may be the cause of your problems. Uninstall the older versions via "Programs and features" in the control panel of windows.
im trying to code in typescript using Angular library, and everytime i try to compile just give me 482 errors, where most of them are "TS 2304 Cannot find a name 'Promise'". I canĀ“t fix this. Just a note, if i unistall angular library, it compiles with no error.
I install Angular 1.5, and Angular.d.ts requires Angular 1.4+, so no problem here.
I try to reinstall multiple times, still no changes.
For angular.d.ts i used a nuget package named angularjs.typescript.definitelytyped. Im using visual studio 2015 Update 1, with all the updates available today.
According to Daniel Rosenwasser's comment I added the core-js d.ts with
PM> Install-Package core-js.TypeScript.DefinitelyTyped
That solved the problem for me.
I have VS 2013 Update 4, TS 1.4, latest WebEssentials and R# 8.
I am trying to create some AngularJS code in my MVC solution.
In installed Angularjs and angular.d.ts via nuget. I have done the same for "marked" and also jQuery installed automatically as Angular dependency.
How, none of Angular types get resolved by Intellisense. If I am trying to type "mar" in an empty TypeScript file I get this:
If I type "jque" I get this:
But when I type "ang" - nothing.
All d.ts files are in place:
Adding reference path directive does not help, although it is not required and Intellisense works perfectly fine for other frameworks. Manual typing without Intellisense support works fine and I get no compilation errors, so TSLint and tsc are ok with my code.
So, my question is - what is going on there?
P.S. Just added Knockout to test this and typing "ko" brings proper Intellisense.
P.P.S. I turned off the TS support in R# and intellisense seems to work properly. So, I would assume this is the Resharper issue.
I turned off the TS support in R# and intellisense seems to work properly. So, I would assume this is the Resharper issue
Yes. They need to update for v1.4 of typescript. You can use an older angular.d.ts till then : https://github.com/borisyankov/DefinitelyTyped/blob/1.3.0/angularjs/angular.d.ts
As basart mentioned, rather than installing EAP or turning Resharper off, you can use an older version of the file for the interim period. But I advise against adding it manually in your solution. Version 1.7.4 of jQuery d.ts and version 2.4.0 of Angular d.ts worked for me and you can use NuGet from the Package Manager command line in Visual Studio to install them.
Install-Package jquery.TypeScript.DefinitelyTyped -Version 1.7.4
Install-Package angularjs.TypeScript.DefinitelyTyped -Version 2.4.0
Make sure you select your project in the dropdown box inside the console before running the command.
I had this problem a little earlier today, where inline intellisense was flagging angular, as well as various interfaces (usually IPromise<T>) as not being found, despite having reference metacomments and the files present in my project.
Similar to the answer from #basarat, I was able to disable ReSharper Intellisense (Resharper | Options... | Intellisense | General), restart Visual Studio, and then re-enable TypeScript Intellisense. Upon re-enabling intellisense, I no longer get red squigglies.
I did this in Visual Studio 2015, ReSharper 2016.3.2, on a project that is using Angular 1.6 and TypeScript together, with no tsconfig.json file (configuration is done in the TypeScript tab of the Web project.)
I have a problem with Visual Studio 2013 generating too many errors when building a web application with typescript definition files. For example consider the following scenario:
Start a new Empty Web Application
Right click on project and select Manage Nuget Packages
Add jquery and jquery typings (the typings I downloaded are a couple of days old)
Build the project
Project builds successfully with more than 100 errors (errors, not warnings), all in jquery.d.ts, like the following:
',' expected.
'=' expected.
Identifier expected.
I get similar results when I do the same with angularjs instead of jquery.
Any ideas?
The most likely reason for this is that you are using an older version of TypeScript than the definition author.
The language is moving swiftly and some of the features in version 1.4 are particularly useful in definition files, so it is likely that you will need to upgrade to 1.4 so that your machine can understand these new features.
Download version 1.4 here.
I was having a similar issues like this but I was able to resolve the jQuery issues by downgrading my DefinitelyTyped version of "1.0.1" instead of "1.4.1". Also I'm currently running on Mac and hopefully this can help users who are experiencing issues on Mac.