Definitelytyped: Compilation errors in @types/jasmine v.2.5.42

Created on 11 Feb 2017  ·  20Comments  ·  Source: DefinitelyTyped/DefinitelyTyped

  • [x] I tried using the @types/jasmine package and had problems.
  • [x] I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript
  • [x] I have a question that is inappropriate for StackOverflow. (Please ask any appropriate questions there).
  • [x] [Mention](https://github.com/blog/821-mention-somebody-they-re-notified) the authors (see Definitions by: in index.d.ts) so they can respond.

    • Authors: @borisyankov, @theodorejb, @davidparsson

When I try to compile my project I get the next error:

ERROR in [at-loader] node_modules/@types/jasmine/index.d.ts:39:52
    TS1005: '=' expected.

ERROR in [at-loader] node_modules/@types/jasmine/index.d.ts:39:38
    TS2371: A parameter initializer is only allowed in a function or constructor implementation.

ERROR in [at-loader] node_modules/@types/jasmine/index.d.ts:39:46
    TS2304: Cannot find name 'keyof'.

A workaround that I've found is to change to version 2.5.41. I guess that the problem is in the last update of the jasmine typings

Most helpful comment

Had similar issues, downgraded to "@types/jasmine": "2.5.38"

All 20 comments

Related to https://github.com/DefinitelyTyped/DefinitelyTyped/issues/14579

I think that this is not a bug of the new jasmine typing itself, rather a bug of compatibility checking between your TypeScript version and the published type (the typing states it needs 2.1+ using a special comment). Maybe it does not work the way I expected... but then how it should work?..

You could either downgrade the version of typing or upgrade your TS to 2.1+ (from 2.0).

However, it is still not clear why no kind of validation is triggered when you're updating @types, why you are not prevented from updating to an incompatible version... that's what is weird.

Could you also examine this thread: https://github.com/Microsoft/types-publisher/issues/214 , please?

If I get it right, according to the discussion, TypeScript 2.1 is a stable and a backward-compatible version with 2.0 and since 30 days grace period has already passed, so the best solution is to upgrade to 2.1.

Otherwise, you can downgrade the @types/jasmine version, but at the end of the day, you'll have to upgrade to TS 2.1 sometime anyway.

Thanks to @noomorph, the suggestion to upgrade to v2.1.x (from v2.0.x) worked for me.

Had similar issues, downgraded to "@types/jasmine": "2.5.38"

If you're not using Angular 2, update your TypeScript to 2.1.6 or higher, please. This should help.

According to the thread you should not restrict updating your typescript devDependency to numbers like 2.0.10 or ~2.0.10.

Instead, you need to loosen the dependency on TypeScript version: ^2.0.0, so the version you download will be greater than 2.1.0.

Using 2.0.x is considered legacy since 2.1.x is backwards-compatible in the vast majority of cases.

Downgrading Jasmine typing version

TypeScript 2.1 support has been incorporated into Angular 4.x but the backport is still not done for Angular 2.

If you have Angular 2 project or another serious reason to stay on ~2.0.x, then you should downgrade @types/jasmine to 2.5.41. Please mind that the latter is only a temporary solution because at the end of the day other typings will also start using new TypeScript syntax and may also break the build in the same way.

Applying this kind of solution (freezing a specific version number) may cause another issue in the future when you stop receiving typings for the updated libraries' versions without even noticing that.

Tip regarding @types installation

If you're aware that your project sticks to some specific version of TypeScript (e.g. 2.0), then you should install @types/foo via command npm install @types/[email protected]. However, it does not help if you run npm update, so be attentive.

@noomorph, I have Typescript 2.1.1 and still issues with typings (lodash, jasmine, and probably other too), so your solution does not seems to work. Any hints?

@Marooned-MB , it's hard to tell without any package.json or compilation errors.

A parameter initializer is only allowed in a function or constructor implementation. so the same error as in 1st post

@Marooned-MB , by the way, TypeScript 2.1.1 indeed has an error (I updated the header in my comment above), thanks for the report. I get something like this on 2.1.1:

index.d.ts(39,52): error TS1005: '=' expected.

Could try to update to 2.1.6? Please make sure you're running exactly 2.1.6 by executing inside your project's directory:

node_modules/.bin/tsc --version

Expected output:

Version 2.1.6

After upgrading TS to 2.1.6 this seems to be resolved however I have lots of other issues with dependencies, so I guess I'm stuck a bit. Thanks anyway, I'll talk to the team about it. Thanks for your help.

Upgrading TS version didn't work for me as well. Only downgrading the @types/jasmine version helped. Thanks for the workaround!

I've encountered the same error. Downgrading to previous version also worked.

Same issue with:

├── core-js (global)
├── jasmine (global)
├── jquery (global)
├── node (global)
└── signalr (global)

Downgrading to typescript 2.1.6 worked. Latest didn't.

I have typescript 2.0.3 and jasmine 2.5.38. Have the same problem. Cant upgrade typescript becuase of angular 2.

I have the same issue with Typescript 2.6.0-rc and Jasmine 2.6.2.

tsconfig.json

{
    "compilerOptions": {
        "baseUrl": ".",
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "module": "commonjs",
        "moduleResolution": "node",
        "strict": true,
        "noFallthroughCasesInSwitch": true,
        "sourceMap": true,
        "rootDir": ".",
        "inlineSources": true,
        "noImplicitAny": true,
        "noUnusedLocals": true, 
        "noUnusedParameters": true, 
        "lib": [
            "es6",
            "dom"
        ],
        "target": "es5",
        "skipLibCheck": true,
        "types": [
            "jasmine",
            "node"
        ]
    },
    "exclude": [
        "node_modules"
    ]
}

package.json

    "devDependencies": {
        "@types/jasmine": "^2.6.2",
        "@types/node": "^8.0.47",
        "jasmine-core": "2.6.2",
        "karma": "1.7.0",
        "karma-jasmine": "^1.1.0",
        "tslint": "5.4.0",
        "typescript": "2.6.0-rc",
        "//": "..."
    }

I'm getting this same type of error after upgrading to TS 3.1.

What version of @types/Jasmine should I be using now?

I am facing similar issue
package.json file has
"@types/jasmine": "^2.5.53",
"typescript": "2.3.4"

Here ionic info
Ionic:

ionic (Ionic CLI) : 4.2.1

System:

NodeJS : v8.12.0
npm : 6.4.1
OS : macOS High Sierra

Getting below error while doing ionic build
typescript: node_modules/@types/jasmine/index.d.ts, line: 138 
';' expected.
Error: Failed to transpile program 
Error: Failed to transpile program

can somebody help what went wrong ?

I have had the same problem that SanjanaTailor with following versions:
@types/jasmine 2.8.8
@angular 5.2
typescript 2.5.3
My solution has been upgrading typescript to 3.1.6.
The problen si that Angular shows a Warning because it expects a typescript version lower than 2.7.

I had this issue just in travis enviroment and changin to 2.5.38 worked!

https://travis-ci.org/mariohmol/ng-gantt/builds/459888259

@isawk works great, Thanks :)

Was this page helpful?
0 / 5 - 0 ratings