Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React + Typescript error on build in node_modules/jest-diff/build/diffLines.d.ts

i am currently working on a project that uses React and Typescript that was working just fine until lately where the following error happened when building using Jenkins (and the error appears too in intellij on my computer). It seems that a module as a compilation error.

[INFO] Creating an optimized production build...
[INFO] Failed to compile.
[INFO] 
[INFO] /jenkins/workspace/project/front/node_modules/jest-diff/build/diffLines.d.ts
[INFO] TypeScript error in /jenkins/workspace/project/front/node_modules/jest-diff/build/diffLines.d.ts(8,13):
[INFO] '=' expected.  TS1005
[INFO] 
[INFO]      6 |  */
[INFO]      7 | import { Diff } from './cleanupSemantic';
[INFO]   >  8 | import type { DiffOptions } from './types';
[INFO]        |             ^
[INFO]      9 | export declare const diffLinesUnified: (aLines: string[], bLines: string[], options?: DiffOptions | undefined) => string;
[INFO]     10 | export declare const diffLinesUnified2: (aLinesDisplay: string[], bLinesDisplay: string[], aLinesCompare: string[], bLinesCompare: string[], options?: DiffOptions | undefined) => string;
[INFO]     11 | export declare const diffLinesRaw: (aLines: string[], bLines: string[]) => Diff[];

I am a bit lost here, so anyone has any clue to solve this problem ? Thanks in advance.

Here is my package.json file

{
  "name": "front",
  "version": "1.0.0-SNAPSHOT",
  "private": true,
  "homepage": "./",
  "dependencies": {
    "@types/echarts": "4.1.11",
    "@types/jest": "24.0.15",
    "@types/node": "12.6.3",
    "@types/react": "16.8.23",
    "@types/react-dom": "16.8.4",
    "antd": "3.20.3",
    "axios": "0.19.0",
    "classnames": "2.2.6",
    "connected-react-router": "6.3.1",
    "css-element-queries": "1.2.1",
    "echarts": "4.2.1",
    "jsonwebtoken": "8.5.1",
    "rc-texty": "0.2.0",
    "rc-tween-one": "2.6.3",
    "react": "16.8.6",
    "react-compound-slider": "2.2.0",
    "react-dom": "16.8.6",
    "react-redux": "7.1.0",
    "react-router": "4.4.0-beta.7",
    "react-router-config": "5.0.0",
    "react-router-dom": "4.4.0-beta.7",
    "react-scripts": "3.3.0",
    "redux": "4.0.4",
    "redux-logger": "3.0.6",
    "reflect-metadata": "0.1.13",
    "tailwindcss": "1.1.2",
    "typescript": "3.5.3"
  },
  "scripts": {
    "start": "react-app-rewired start",
    "build": "react-app-rewired build",
    "test": "react-app-rewired test --env=jsdom --watchAll=false",
    "test:watch": "react-app-rewired test --env=jsdom",
    "lint:ts": "eslint ./src/**/*.{ts,tsx}",
    "lint:ts:errors": "eslint ./src/**/*.{ts,tsx} --quiet",
    "lint:ts:fix": "eslint ./src/**/*.{ts,tsx} --fix",
    "madge": "madge --circular --extensions ts ./src/",
    "lint:scss": "stylelint ./src/**/*.scss --syntax scss",
    "lint:scss:fix": "stylelint ./src/**/*.scss --syntax scss --fix"
  },
  "lint-staged": {
    "*.ts": "npm run lint:ts:errors",
    "*.tsx": "npm run lint:ts:errors"
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "jest": {
    "moduleNameMapper": {
      "^@/(.*)$": "<rootDir>/src/$1"
    }
  },
  "browserslist": [
    ">0.2%",
    "ie 11"
  ],
  "devDependencies": {
    "@babel/parser": "7.5.0",
    "@types/classnames": "2.2.9",
    "@types/enzyme": "3.9.1",
    "@types/enzyme-adapter-react-16": "1.0.5",
    "@types/file-saver": "2.0.1",
    "@types/jsonwebtoken": "8.3.2",
    "@types/react-redux": "7.1.1",
    "@types/react-router": "4.4.4",
    "@types/react-router-config": "1.1.2",
    "@types/react-router-dom": "4.3.1",
    "@types/redux-logger": "3.0.7",
    "awesome-typescript-loader": "5.2.1",
    "babel-plugin-import": "1.11.0",
    "cross-env": "5.2.0",
    "customize-cra": "0.2.12",
    "enzyme": "3.9.0",
    "enzyme-adapter-react-16": "1.12.1",
    "file-saver": "2.0.1",
    "husky": "3.0.5",
    "jest-enzyme": "7.0.2",
    "less": "3.9.0",
    "less-loader": "5.0.0",
    "lint-staged": "9.2.5",
    "madge": "3.4.4",
    "node-sass": "4.12.0",
    "prettier": "1.18.2",
    "react-app-polyfill": "1.0.1",
    "react-app-rewire-postcss": "3.0.2",
    "react-app-rewired": "2.1.3",
    "scss-to-json": "2.0.0",
    "stylelint": "11.0.0",
    "stylelint-config-recommended-scss": "4.0.0",
    "stylelint-config-standard": "19.0.0",
    "stylelint-scss": "3.11.1"
  },
  "engines": {
    "node": ">=8"
  }
}
like image 612
Jib'z Avatar asked May 13 '20 19:05

Jib'z


1 Answers

Type-only imports and exports is supported from Typescript 3.8.0.

Set Typescript version >= 3.8.0 to resolve this error.

like image 187
vicacid Avatar answered Sep 21 '22 14:09

vicacid