Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on chai types #19415

Closed
fasatrix opened this issue Aug 29, 2017 · 4 comments
Closed

Error on chai types #19415

fasatrix opened this issue Aug 29, 2017 · 4 comments

Comments

@fasatrix
Copy link

fasatrix commented Aug 29, 2017

Hi, I am resonably new to typescript and mocha/chai in general. I am trying to replicate my work configuration (Windows 8) on my home computer (Windows 10) and I get the following error from the compiler (at work all works fine):

C:\dev\bookapi\mocha-api-test>tsc
node_modules/@types/chai/index.d.ts(1244,15): error TS2451: Cannot redeclare block-scoped variable 'chai'.
test/get-books-200ok.test.ts(24,5): error TS2451: Cannot redeclare block-scoped variable 'chai'.

This is my package.json:
{
"name": "mocha-api-test",
"version": "1.0.0",
"private": true,
"description": "BookAPI",
"scripts": {
"test": "mocha --reporter mocha-junit-reporter -r ts-node/register test/**/*.test.ts"
},
"license": "ISC",
"dependencies": {
"@types/chai": "^3.4.35",
"@types/chai-http": "0.0.30",
"@types/chai-json-schema": "^1.4.2",
"@types/mocha": "^2.2.39",
"@types/node": "^7.0.5",
"chai": "^3.5.0",
"chai-http": "^3.0.0",
"chai-json-schema": "^1.4.0",
"mocha": "^3.2.0",
"mocha-junit-reporter": "^1.13.0",
"ts-node": "^3.1.0",
"typescript": "^2.4.1"
}
}

and this is the tsconfig.ts:
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": false,
"sourceMap": false,
"outDir": "./build",
"typeRoots": [
"node_modules/@types"
],
"types": [
"mocha",
"node",
"chai",
"chai-http",
"chai-json-schema"
]
},
"exclude": [
"node_modules",
"build"
]
}

Thanks for any help

@fasatrix fasatrix changed the title Hi, Hi, I am trying to replicate the work configuration (Windows 8) on my home computer (Wondows 10) and I get the following error from the compiler: Aug 29, 2017
@fasatrix fasatrix changed the title Hi, I am trying to replicate the work configuration (Windows 8) on my home computer (Wondows 10) and I get the following error from the compiler: Error on chai types Aug 29, 2017
@fasatrix
Copy link
Author

found the solutions thanks anyway.. can be closed

@ShayanAhmad
Copy link

could you please tell me the fix for this error?

@perf2711
Copy link

If anyone has this problem, double-check if you're not importing ts-node multiple times. In my case, I was importing it in command (mocha -r ts-node/register) and in mocha.opts (--require ts-node/register).

@EdwardIII
Copy link

To anyone else having the same issue: I found the resolution here: #19480 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants