In one of the projects I’m currently working on we’re using an ASP.NET Core Web API with an Angular front-end. We’re using ADAL.js as an Azure Active Directory Authentication Library and ng2-adal for integration with Angular. To get the type declarations for all these packages in TypeScript we use The Future of Declaration Files.

Some time ago, our build server started acting up with the following message:

Type 'Observable<void>' is not assignable to type 'Observable<User>'

The error occured in ADAL.service.ts, at line 133 to be precise. After quite some investigation I discovered that the issue was in package.json:

  "devDependencies": {
    "typescript": "^2.3.2",

Based on Semantic Versioning the caret (^) indicates the package will update to the most recent minor version. So ^2.3.2 means 2.4.0 will be accepted but 3.0.0 will not. Looking at all version changes of used npm packages on the build server showed there was a new version of TypeScript: 2.4.0. I removed the caret to try and fix the issue, which it did. Life was great and we could all continue with business as usual.

The issue

I recently got a new laptop. Or actually a new (and awesome) Surface Pro but more on that later. The device was prepared before I got it, so a lot of tools like Visual Studio were already installed. I added my personal toolbox to it, cloned our Git repo and started working. The first time I built the solution I got an error:

Type 'Observable<void>' is not assignable to type 'Observable<User>'

Wait, what? I solved that one! I tried lots of stuff to fix this one: from clearing my complete npm cache to matching all npm package versions up to patch level with the ones used on the build server. All to no avail. Since none of my colleagues working on the same project had any issues, and matching the package versions of the build server didn’t help it was probably a tooling issue.

Solution

Typescript logoAfter looking at the tools I had on my machine, I noticed the version of the TypeScript SDK. It was version 2.4.1 which is the latest version. And although the TypeScript version in packages.json was explicitly set to 2.3.3 I wasn’t quite sure these would play nice together. I removed the TypeScript SDK and installed an older version (2.3.3). Because of just a bit of built-up frustration I was skeptical this would work, but it did! I’ll be investigating the details later but for now I have a functioning environment again. So me == happy 🙂

Hope this helps.