TypeScript declaration files for Jasmine not found in Angular 2 project

Created on 14 Oct 2016  路  8Comments  路  Source: microsoft/TypeScript

_From @jorgeas80 on October 1, 2016 18:8_

  • VSCode Version: 1.5.3
  • OS Version: Ubuntu 16.04

Steps to Reproduce:

  1. Install angular-cli
  2. Run ng new myproject
  3. Open the created project with VSCode, and open the spec file (src/app/app.component.spec.ts)

Functions like describe, beforeEach, it and expect are not recognized (see img)

Jasmine ts types not found

Check list:

  • node_modules/@types/jasmine/index.d.ts file exist
  • this option is included in tsconfig.json
"typeRoots": [
      "../node_modules/@types"
    ]

As tsd is officially deprecated since August and I'm using the last VSCode release, why could be happening?

_Copied from original issue: Microsoft/vscode#13125_

VS Code Tracked

Most helpful comment

I was able to reproduce the above error,but was able to resolve it by adding an explicit typing to my tsconfig.json file

image

This is based on http://stackoverflow.com/questions/39020022/angular-2-unit-tests-cannot-find-name-describe.

All 8 comments

_From @jorgeas80 on October 2, 2016 11:2_

I had to add this to make vscode recognize Jasmine typings.

/// <reference path="../../../node_modules/@types/jasmine/index.d.ts" />

It shouldn't be necessary with my version, I think

@jorgeas80 thank you for opening this issue.

@mhegazy can you take a look at this? I have recreated this on my own machine. As far as I can tell everything is setup correctly: tsconfig.json, typings exist in the proper location, etc. Seems like I'm missing a config step though...

_From @blakehawkins on October 11, 2016 14:37_

I have a similar configuration with the same issue - no angular.

  • vscode 1.5.3
  • ubuntu 16.04

Steps to reproduce:

  1. npm install @types/es6-shim
  2. Add "compilerOptions": {"typeRoots": ["./node_modules/@types/"]} kv to tsconfig.json
  3. code displays an error at, for example, const features = new Set(arr);

Can also confirm that compiling with tsc succeeds.

@blakehawkins thank you for providing more information. This is a language service issue. Moving to that repo.

I am unable to reproduce this locally on latest. please reopen if you are still experiencing issues.

I have this same issue in a Nativescript with Angular 2 project, Jasmine functions are not recognized

@magar91 can you share a repo that we can reproduce the issue?

I was able to reproduce the above error,but was able to resolve it by adding an explicit typing to my tsconfig.json file

image

This is based on http://stackoverflow.com/questions/39020022/angular-2-unit-tests-cannot-find-name-describe.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DanielRosenwasser picture DanielRosenwasser  路  3Comments

MartynasZilinskas picture MartynasZilinskas  路  3Comments

kyasbal-1994 picture kyasbal-1994  路  3Comments

jbondc picture jbondc  路  3Comments

zhuravlikjb picture zhuravlikjb  路  3Comments