ts-jest cant find jest typings

Created on 27 Nov 2018  路  18Comments  路  Source: kulshekhar/ts-jest

Issue :

Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try npm i @t ypes/jest or npm i @types/mocha.

@types/jest is installed
https://github.com/TrigenSoftware/flexis-favicons/blob/ts-jest/package.json#L47

same setup perfectly works with old ts-jest
https://github.com/TrigenSoftware/flexis-favicons/blob/master/package.json#L63

Debug log:


log file content

# content of ts-jest.log :
{"context":{"logLevel":20,"namespace":"Importer","package":"ts-jest","version":"23.10.5"},"message":"creating Importer singleton","sequence":1,"time":"2018-11-25T22:28:36.935Z"}
{"context":{"allowJs":false,"logLevel":20,"namespace":"jest-preset","package":"ts-jest","version":"23.10.5"},"message":"creating jest presets not handling JavaScript files","sequence":2,"time":"2018-11-25T22:28:36.969Z"}
{"context":{"actualVersion":"23.6.0","expectedVersion":">=22 <24","logLevel":20,"namespace":"versions","package":"ts-jest","version":"23.10.5"},"message":"checking version of jest: OK","sequence":3,"time":"2018-11-25T22:28:36.982Z"}
{"context":{"baseOptions":{},"logLevel":20,"namespace":"jest-transformer","package":"ts-jest","transformerId":1,"version":"23.10.5"},"message":"created new transformer","sequence":4,"time":"2018-11-25T22:28:36.983Z"}
{"context":{"fileName":"/Users/dangreen/github/flexis-favicons/src/getHtmlHeadersMarkup.ts","logLevel":20,"namespace":"jest-transformer","package":"ts-jest","transformOptions":{"instrument":false,"rootDir":"/Users/dangreen/github/flexis-favicons"},"transformerId":1,"version":"23.10.5"},"message":"computing cache key for /Users/dangreen/github/flexis-favicons/src/getHtmlHeadersMarkup.ts","sequence":5,"time":"2018-11-25T22:28:37.035Z"}
{"context":{"logLevel":30,"namespace":"jest-transformer","package":"ts-jest","transformerId":1,"version":"23.10.5"},"message":"no matching config-set found, creating a new one","sequence":6,"time":"2018-11-25T22:28:37.036Z"}
{"context":{"config":{"automock":false,"browser":false,"cache":true,"cacheDirectory":"/var/folders/jx/twfr9ct54275nn4y4xwv2d2w0000gn/T/jest_dx","clearMocks":false,"coveragePathIgnorePatterns":["/node_modules/"],"cwd":"/Users/dangreen/github/flexis-favicons","detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"filter":null,"forceCoverageMatch":[],"globals":{"ts-jest":{"babelConfig":{"presets":[["babel-preset-trigen",{"commonjs":true}]]}}},"haste":{"providesModuleNodeModules":[]},"moduleDirectories":["node_modules"],"moduleFileExtensions":["ts","tsx","js","jsx","json"],"moduleNameMapper":{},"modulePathIgnorePatterns":[],"name":"a839c2587546d1a644dca5e5313020fa","prettierPath":null,"resetMocks":false,"resetModules":false,"resolver":null,"restoreMocks":false,"rootDir":"/Users/dangreen/github/flexis-favicons","roots":["/Users/dangreen/github/flexis-favicons"],"runner":"jest-runner","setupFiles":[],"setupTestFrameworkScriptFile":null,"skipFilter":false,"snapshotSerializers":[],"testEnvironment":"/Users/dangreen/github/flexis-favicons/node_modules/jest-environment-node/build/index.js","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":[],"testPathIgnorePatterns":["/node_modules/"],"testRegex":"/test/.*\\.spec\\.ts$","testRunner":"/Users/dangreen/github/flexis-favicons/node_modules/jest-jasmine2/build/index.js","testURL":"http://localhost","timers":"real","transform":[["^.+\\.tsx?$","/Users/dangreen/github/flexis-favicons/node_modules/ts-jest/dist/index.js"]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"logLevel":20,"namespace":"backports","package":"ts-jest","transformerId":1,"version":"23.10.5"},"message":"backporting config","sequence":7,"time":"2018-11-25T22:28:37.038Z"}
{"context":{"jestConfig":{"automock":false,"browser":false,"cache":true,"cacheDirectory":"/var/folders/jx/twfr9ct54275nn4y4xwv2d2w0000gn/T/jest_dx","clearMocks":false,"coveragePathIgnorePatterns":["/node_modules/"],"cwd":"/Users/dangreen/github/flexis-favicons","detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"filter":null,"forceCoverageMatch":[],"globals":{"ts-jest":{"babelConfig":{"presets":[["babel-preset-trigen",{"commonjs":true}]]}}},"haste":{"providesModuleNodeModules":[]},"moduleDirectories":["node_modules"],"moduleFileExtensions":["ts","tsx","js","jsx","json"],"moduleNameMapper":{},"modulePathIgnorePatterns":[],"name":"a839c2587546d1a644dca5e5313020fa","prettierPath":null,"resetMocks":false,"resetModules":false,"resolver":null,"restoreMocks":false,"rootDir":"/Users/dangreen/github/flexis-favicons","roots":["/Users/dangreen/github/flexis-favicons"],"runner":"jest-runner","setupFiles":[],"setupTestFrameworkScriptFile":null,"skipFilter":false,"snapshotSerializers":[],"testEnvironment":"/Users/dangreen/github/flexis-favicons/node_modules/jest-environment-node/build/index.js","testEnvironmentOptions":{},"testLocationInResults":false,"testMatch":[],"testPathIgnorePatterns":["/node_modules/"],"testRegex":"/test/.*\\.spec\\.ts$","testRunner":"/Users/dangreen/github/flexis-favicons/node_modules/jest-jasmine2/build/index.js","testURL":"http://localhost","timers":"real","transform":[["^.+\\.tsx?$","/Users/dangreen/github/flexis-favicons/node_modules/ts-jest/dist/index.js"]],"transformIgnorePatterns":["/node_modules/"],"watchPathIgnorePatterns":[]},"logLevel":20,"namespace":"config","package":"ts-jest","transformerId":1,"version":"23.10.5"},"message":"normalized jest config","sequence":8,"time":"2018-11-25T22:28:37.039Z"}
{"context":{"logLevel":20,"namespace":"config","package":"ts-jest","transformerId":1,"tsJestConfig":{"babelConfig":{"kind":"inline","value":{"presets":[["babel-preset-trigen",{"commonjs":true}]]}},"compiler":"typescript","diagnostics":{"ignoreCodes":[6059,18002,18003],"pretty":true,"throws":true},"isolatedModules":false,"transformers":[],"tsConfig":{"kind":"file"}},"version":"23.10.5"},"message":"normalized ts-jest config","sequence":9,"time":"2018-11-25T22:28:37.040Z"}
{"context":{"logLevel":20,"namespace":"Importer","package":"ts-jest","requireResult":{"exists":true,"given":"babel-core","path":"/Users/dangreen/github/flexis-favicons/node_modules/babel-core/index.js"},"version":"23.10.5"},"message":"loaded module babel-core","sequence":10,"time":"2018-11-25T22:28:37.320Z"}
{"context":{"logLevel":20,"namespace":"Importer","package":"ts-jest","version":"23.10.5"},"message":"patching babel-core","sequence":11,"time":"2018-11-25T22:28:37.320Z"}
{"context":{"actualVersion":"7.0.0-bridge.0","expectedVersion":">=6 <7 || 7.0.0-bridge.0","logLevel":20,"namespace":"versions","package":"ts-jest","version":"23.10.5"},"message":"checking version of babel-core: OK","sequence":12,"time":"2018-11-25T22:28:37.330Z"}
{"context":{"babelConfig":{"babelrc":false,"configFile":false,"cwd":"/Users/dangreen/github/flexis-favicons","envName":"test","passPerPreset":false,"plugins":[{"key":"/Users/dangreen/github/flexis-favicons/node_modules/@babel/plugin-syntax-dynamic-import/lib/index.js","options":{},"visitor":{}},{"key":"/Users/dangreen/github/flexis-favicons/node_modules/@babel/plugin-syntax-import-meta/lib/index.js","options":{},"visitor":{}},{"key":"/Users/dangreen/github/flexis-favicons/node_modules/@babel/plugin-proposal-class-properties/lib/index.js","options":{},"visitor":{"ClassDeclaration":{"enter":[null]},"ClassExpression":{"enter":[null]},"PrivateName":{"enter":[null]},"_exploded":{},"_verified":{}}},{"key":"/Users/dangreen/github/flexis-favicons/node_modules/@babel/plugin-proposal-json-strings/lib/index.js","options":{},"visitor":{"DirectiveLiteral":{"enter":[null]},"StringLiteral":{"enter":[null]},"_exploded":{},"_verified":{}}},{"key":"/Users/dangreen/github/flexis-favicons/node_modules/@babel/plugin-proposal-decorators/lib/index.js","options":{"legacy":true},"visitor":{"AssignmentExpression":{"enter":[null]},"ClassDeclaration":{"enter":[null]},"ClassExpression":{"enter":[null]},"ExportDefaultDeclaration":{"enter":[null]},"ObjectExpression":{"enter":[null]},"_exploded":{},"_verified":{}}},{"key":"/Users/dangreen/github/flexis-favicons/node_modules/@babel/plugin-proposal-function-sent/lib/index.js","options":{},"visitor":{"MetaProperty":{"enter":[null]},"_exploded":{},"_verified":{}}},{"key":"/Users/dangreen/github/flexis-favicons/node_modules/@babel/plugin-proposal-export-namespace-from/lib/index.js","options":{},"visitor":{"ExportNamedDeclaration":{"enter":[null]},"_exploded":{},"_verified":{}}},{"key":"/Users/dangreen/github/flexis-favicons/node_modules/@babel/plugin-proposal-numeric-separator/lib/index.js","options":{},"visitor":{"CallExpression":{"enter":[null]},"NewExpression":{"enter":[null]},"NumericLiteral":{"enter":[null]},"_exploded":{},"_verified":{}}},{"key":"/Users/dangreen/github/flexis-favicons/node_modules/@babel/plugin-proposal-throw-expressions/lib/index.js","options":{},"visitor":{"UnaryExpression":{"enter":[null]},"_exploded":{},"_verified":{}}},{"key":"/Users/dangreen/github/flexis-favicons/node_modules/@babel/plugin-proposal-export-default-from/lib/index.js","options":{},"visitor":{"ExportNamedDeclaration":{"enter":[null]},"_exploded":{},"_verified":{}}},{"key":"/Users/dangreen/github/flexis-favicons/node_modules/@babel/plugin-proposal-async-generator-functions/lib/index.js","options":{},"visitor":{"Program":{"enter":[null]},"_exploded":{},"_verified":{}}},{"key":"/Users/dangreen/github/flexis-favicons/node_modules/@babel/plugin-transform-runtime/lib/index.js","options":{},"visitor":{"BinaryExpression":{"enter":[null]},"CallExpression":{"enter":[null]},"Identifier":{"enter":[null]},"JSXIdentifier":{"enter":[null]},"MemberExpression":{"enter":[null],"exit":[null]},"_exploded":true,"_verified":true}},{"key":"/Users/dangreen/github/flexis-favicons/node_modules/@babel/preset-env/lib/index.js$0","options":{"loose":false},"visitor":{"Program":{"exit":[null]},"_exploded":true,"_verified":true}},{"key":"/Users/dangreen/github/flexis-favicons/node_modules/@babel/preset-env/lib/index.js$1","options":{"loose":false,"spec":false,"useBuiltIns":true},"visitor":{"RegExpLiteral":{"enter":[null]},"_exploded":true,"_verified":true}},{"key":"/Users/dangreen/github/flexis-favicons/node_modules/@babel/preset-env/lib/index.js$2","options":{"loose":false,"spec":false,"useBuiltIns":true},"visitor":{"AssignmentExpression":{"enter":[null]},"BinaryExpression":{"enter":[null]},"_exploded":true,"_verified":true}},{"key":"/Users/dangreen/github/flexis-favicons/node_modules/@babel/preset-env/lib/index.js$3","options":{"loose":false,"spec":false,"useBuiltIns":true},"visitor":{"ArrowFunctionExpression":{"enter":[null]},"ClassMethod":{"enter":[null]},"FunctionDeclaration":{"enter":[null]},"FunctionExpression":{"enter":[null]},"ObjectMethod":{"enter":[null]},"_exploded":true,"_verified":true}},{"key":"/Users/dangreen/github/flexis-favicons/node_modules/@babel/preset-env/lib/index.js$4","options":{"loose":false,"spec":false,"useBuiltIns":true},"visitor":{"Program":{"enter":[null]},"_exploded":{},"_verified":{}}},{"key":"/Users/dangreen/github/flexis-favicons/node_modules/@babel/preset-env/lib/index.js$5","options":{"loose":false,"spec":false,"useBuiltIns":true},"visitor":{"ArrowFunctionExpression":{"enter":[null]},"AssignmentExpression":{"enter":[null]},"CatchClause":{"enter":[null]},"ClassMethod":{"enter":[null]},"ExportNamedDeclaration":{"enter":[null]},"ForInStatement":{"enter":[null]},"ForOfStatement":{"enter":[null]},"FunctionDeclaration":{"enter":[null]},"FunctionExpression":{"enter":[null]},"ObjectExpression":{"enter":[null]},"ObjectMethod":{"enter":[null]},"VariableDeclarator":{"enter":[null]},"_exploded":{},"_verified":{}}},{"key":"/Users/dangreen/github/flexis-favicons/node_modules/@babel/preset-env/lib/index.js$6","options":{"loose":false,"spec":false,"useBuiltIns":true},"visitor":{"RegExpLiteral":{"enter":[null]},"_exploded":true,"_verified":true}},{"key":"/Users/dangreen/github/flexis-favicons/node_modules/@babel/preset-env/lib/index.js$7","options":{"loose":false,"spec":false,"useBuiltIns":true},"visitor":{"DirectiveLiteral":{"enter":[null]},"StringLiteral":{"enter":[null]},"_exploded":{},"_verified":{}}},{"key":"/Users/dangreen/github/flexis-favicons/node_modules/@babel/preset-env/lib/index.js$8","options":{"loose":false,"spec":false,"useBuiltIns":true},"visitor":{"CatchClause":{"enter":[null]},"_exploded":{},"_verified":{}}},{"key":"use-built-ins","options":{"debug":false,"polyfills":{},"regenerator":false},"visitor":{"ArrowFunctionExpression":{"enter":[null]},"BinaryExpression":{"enter":[null]},"CallExpression":{"enter":[null]},"ClassMethod":{"enter":[null]},"FunctionDeclaration":{"enter":[null]},"FunctionExpression":{"enter":[null]},"Identifier":{"enter":[null]},"ImportDeclaration":{"enter":[null]},"JSXIdentifier":{"enter":[null]},"MemberExpression":{"enter":[null],"exit":[null]},"ObjectMethod":{"enter":[null]},"Program":{"enter":[null]},"VariableDeclarator":{"enter":[null]},"YieldExpression":{"enter":[null]},"_exploded":true,"_verified":true}}],"presets":[],"root":"/Users/dangreen/github/flexis-favicons"},"logLevel":20,"namespace":"config","package":"ts-jest","transformerId":1,"version":"23.10.5"},"message":"normalized babel config","sequence":13,"time":"2018-11-25T22:28:38.196Z"}
{"context":{"logLevel":20,"namespace":"Importer","package":"ts-jest","requireResult":{"exists":true,"given":"typescript","path":"/Users/dangreen/github/flexis-favicons/node_modules/typescript/lib/typescript.js"},"version":"23.10.5"},"message":"loaded module typescript","sequence":14,"time":"2018-11-25T22:28:38.752Z"}
{"context":{"logLevel":20,"namespace":"Importer","package":"ts-jest","version":"23.10.5"},"message":"patching typescript","sequence":15,"time":"2018-11-25T22:28:38.752Z"}
{"context":{"actualVersion":"3.1.6","expectedVersion":">=2.7 <4","logLevel":20,"namespace":"versions","package":"ts-jest","version":"23.10.5"},"message":"checking version of typescript: OK","sequence":16,"time":"2018-11-25T22:28:38.753Z"}
{"context":{"logLevel":20,"namespace":"config","package":"ts-jest","transformerId":1,"tsConfigFileName":"/Users/dangreen/github/flexis-favicons/tsconfig.json","version":"23.10.5"},"message":"readTsConfig(): reading /Users/dangreen/github/flexis-favicons/tsconfig.json","sequence":17,"time":"2018-11-25T22:28:38.753Z"}
{"context":{"logLevel":20,"namespace":"config","package":"ts-jest","transformerId":1,"tsconfig":{"input":{"compilerOptions":{"allowSyntheticDefaultImports":true,"declaration":true,"declarationMap":true,"esModuleInterop":true,"experimentalDecorators":true,"inlineSourceMap":true,"lib":["esnext"],"module":"esnext","moduleResolution":"node","noImplicitAny":false,"noUnusedLocals":true,"noUnusedParameters":true,"target":"esnext","typeRoots":["./types"]},"exclude":["lib/**/*"],"include":["src/index.ts"]},"resolved":{"compileOnSave":false,"configFileSpecs":{"excludeSpecs":["lib/**/*"],"includeSpecs":["src/index.ts"],"validatedExcludeSpecs":["lib/**/*"],"validatedIncludeSpecs":["src/index.ts"],"wildcardDirectories":{}},"errors":[],"fileNames":["/Users/dangreen/github/flexis-favicons/src/index.ts"],"options":{"allowSyntheticDefaultImports":true,"configFilePath":"/Users/dangreen/github/flexis-favicons/tsconfig.json","declaration":false,"esModuleInterop":true,"experimentalDecorators":true,"inlineSourceMap":false,"inlineSources":true,"lib":["lib.esnext.d.ts"],"module":6,"moduleResolution":2,"noEmit":false,"noImplicitAny":false,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"$$ts-jest$$","removeComments":false,"sourceMap":true,"target":6,"typeRoots":["/Users/dangreen/github/flexis-favicons/types"]},"raw":{"compileOnSave":false,"compilerOptions":{"allowSyntheticDefaultImports":true,"declaration":true,"declarationMap":true,"esModuleInterop":true,"experimentalDecorators":true,"inlineSourceMap":true,"lib":["esnext"],"module":"esnext","moduleResolution":"node","noImplicitAny":false,"noUnusedLocals":true,"noUnusedParameters":true,"target":"esnext","typeRoots":["./types"]},"exclude":["lib/**/*"],"include":["src/index.ts"]},"typeAcquisition":{"enable":false,"exclude":[],"include":[]},"wildcardDirectories":{}}},"version":"23.10.5"},"message":"normalized typescript config","sequence":18,"time":"2018-11-25T22:28:38.778Z"}
{"context":{"baseOptions":{},"logLevel":20,"namespace":"jest-transformer","package":"ts-jest","transformerId":2,"version":"23.10.5"},"message":"created new transformer","sequence":19,"time":"2018-11-25T22:28:39.376Z"}
{"context":{"fileName":"/Users/dangreen/github/flexis-favicons/src/renderIcon.ts","logLevel":20,"namespace":"jest-transformer","package":"ts-jest","transformOptions":{"instrument":false,"rootDir":"/Users/dangreen/github/flexis-favicons"},"transformerId":2,"version":"23.10.5"},"message":"computing cache key for /Users/dangreen/github/flexis-favicons/src/renderIcon.ts","sequence":20,"{"context":{"baseOptions":{},"logLevel":20,"namespace":"jest-transformer","package":"ts-jest","transformerId":3,"version":"23.10.5"},"message":"created new transformer","sequence":21,"time":"2018-11-25T22:28:39.621Z"}
{"context":{"fileName":"/Users/dangreen/github/flexis-favicons/src/helpers.ts","logLevel":20,"namespace":"jest-transformer","package":"ts-jest","transformOptions":{"instrument":false,"rootDir":"/Users/dangreen/github/flexis-favicons"},"transformerId":3,"version":"23.10.5"},"message":"computing cache key for /Users/dangreen/github/flexis-favicons/src/helpers.ts","sequence":22,"time":"2018-11-25T22:28:39.621Z"}
58Z"}
{"context":{"baseOptions":{},"logLevel":20,"namespace":"jest-transformer","package":"ts-jest","transformerId":4,"version":"23.10.5"},"message":"created new transformer","sequence":23,"time":"2018-11-25T22:28:39.527Z"}
{"context":{"fileName":"/Users/dangreen/github/flexis-favicons/src/htmlHeaders.ts","logLevel":20,"namespace":"jest-transformer","package":"ts-jest","transformOptions":{"instrument":false,"rootDir":"/Users/dangreen/github/flexis-favicons"},"transformerId":4,"version":"23.10.5"},"message":"computing cache key for /Users/dangreen/github/flexis-favicons/src/htmlHeaders.ts","sequence":24,"time":"2018-11-25T22:28:39.527Z"}

Minimal repo :

https://github.com/TrigenSoftware/flexis-favicons/tree/ts-jest

Most helpful comment

Main issue is that you changed typeRoots in your tsconfig, which by default is node_modules/@types. So then it does not load any typings from there, and jest typings are there

All 18 comments

hi @dangreen, does your IDE also complain that it can't find typing package ?

@ahnpnl I'm using VSCode, and it finds typing packages.

as I said, all works with old version of ts-jest: https://github.com/TrigenSoftware/flexis-favicons

@dangreen your tsconfig includes only src/index.ts, isn't this the issue?

@huafu

1) In master with old ts-jest all works
2) I'm already trying add test files to tsconfig - still doesn't work

  1. old ts-jest does not care about typings neither it handles the notion of project, as it uses isolatedModules by default
  2. k, lemme clone your project and see ;-)

Main issue is that you changed typeRoots in your tsconfig, which by default is node_modules/@types. So then it does not load any typings from there, and jest typings are there

I thought the same @huafu but it doesn't explain why old version works with the same typeRoots declaration. It looks weird to me.

@ahnpnl as I said, old version of ts-jest was compiling each file as isolated module. It could not type-check and it did only care of some options of the compilerOptions from tsconfig. It was not aware about the whole source as a project.
And no type-checking = it did not care if a typing was missing, no error reported.

Got it working with this diff (other issues fixed and config cleaned-up):

diff --git a/jest.config.js b/jest.config.js
new file mode 100644
index 0000000..eabff5e
--- /dev/null
+++ b/jest.config.js
@@ -0,0 +1,23 @@
+module.exports = {
+   preset:              'ts-jest',
+   testEnvironment:     'node',
+   testMatch:           null,
+   testRegex:           '/test/.*\\.spec\\.ts$',
+   collectCoverage:     true,
+   collectCoverageFrom: ['src/**/*.{ts,tsx}', '!**/node_modules/**'],
+   coverageReporters:   ['lcovonly', 'text'],
+   globals:             {
+       'ts-jest': {
+           babelConfig: {
+               presets: [
+                   [
+                       'babel-preset-trigen',
+                       {
+                           commonjs: true
+                       }
+                   ]
+               ]
+           }
+       }
+   }
+};
diff --git a/jest.config.json b/jest.config.json
deleted file mode 100644
index d620fef..0000000
--- a/jest.config.json
+++ /dev/null
@@ -1,34 +0,0 @@
-{
-   "testEnvironment": "node",
-   "moduleFileExtensions": [
-       "ts",
-       "tsx",
-       "js",
-       "jsx",
-       "json"
-   ],
-   "testRegex": "/test/.*\\.spec\\.ts$",
-   "transform": {
-       "^.+\\.tsx?$": "ts-jest"
-   },
-   "collectCoverage": true,
-   "collectCoverageFrom": [
-       "src/**/*.{ts,tsx}",
-       "!**/node_modules/**"
-   ],
-   "coverageReporters": [
-       "lcovonly",
-       "text"
-   ],
-   "globals": {
-       "ts-jest": {
-           "babelConfig": {
-               "presets": [
-                   ["babel-preset-trigen", {
-                       "commonjs": true
-                   }]
-               ]
-           }
-       }
-   }
-}
diff --git a/package.json b/package.json
index d6c011f..39a173e 100644
--- a/package.json
+++ b/package.json
@@ -18,8 +18,8 @@
   },
   "scripts": {
     "generateDocs": "typedoc ./src --out ./docs --ignoreCompilerErrors --excludeExternals --mode modules; touch docs/.nojekyll",
-    "lint": "tslint -p . -t stylish 'src/**/*.{ts,tsx}'",
-    "jest": "NODE_ENV=test jest -c jest.config.json",
+    "lint": "tslint -p tsconfig.build.json -t stylish 'src/**/*.{ts,tsx}'",
+    "jest": "NODE_ENV=test jest",
     "checkSize": "size-limit",
     "test": "npm run lint && npm run jest && npm run build && npm run checkSize",
     "build": "rollup -c",
@@ -44,7 +44,9 @@
   },
   "devDependencies": {
     "@babel/core": "7.1.5",
-    "@types/jest": "^23.3.1",
+    "@types/jest": "^23.3.10",
+    "babel-core": "^7.0.0-0",
+    "babel-jest": "^23.6.0",
     "babel-preset-trigen": "^1.3.0",
     "browserslist-config-trigen": "^1.1.0",
     "clean-publish": "^1.1.0",
@@ -52,7 +54,7 @@
     "eslint": "^5.4.0",
     "eslint-config-trigen": "^3.2.0",
     "husky": "^1.0.0-rc.13",
-    "jest": "^23.5.0",
+    "jest": "^23.6.0",
     "rollup": "^0.67.0",
     "rollup-plugin-babel": "^4.0.2",
     "rollup-plugin-commonjs": "^9.1.6",
@@ -60,7 +62,7 @@
     "rollup-plugin-tslint": "^0.1.35",
     "rollup-plugin-typescript2": "^0.18.0",
     "size-limit": "^0.21.0",
-    "ts-jest": "<23.10.0",
+    "ts-jest": "^23.10.5",
     "tslint": "^5.11.0",
     "tslint-config-trigen": "^3.0.6",
     "typedoc": "^0.13.0",
diff --git a/rollup.config.js b/rollup.config.js
index c3afe3c..ad21650 100644
--- a/rollup.config.js
+++ b/rollup.config.js
@@ -11,7 +11,9 @@ const plugins = [
        throwError: process.env.ROLLUP_WATCH != 'true'
    }),
    commonjs(),
-   typescript(),
+   typescript({
+       tsconfig: './tsconfig.build.json'
+   }),
    babel({
        extensions: [
            ...DEFAULT_EXTENSIONS,
diff --git a/tsconfig.build.json b/tsconfig.build.json
new file mode 100644
index 0000000..11fa1be
--- /dev/null
+++ b/tsconfig.build.json
@@ -0,0 +1,10 @@
+{
+   "extends": "./tsconfig.json",
+   "compilerOptions": {
+       "declaration": true,
+       "declarationMap": true,
+       "inlineSourceMap": true,
+   },
+   "include": ["src/index.ts"],
+   "exclude": ["lib/**/*"]
+}
diff --git a/tsconfig.json b/tsconfig.json
index 57480d3..7e28da9 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,28 +1,16 @@
 {
    "compilerOptions": {
-       "declaration": true,
-       "declarationMap": true,
+       "noEmit": true,
        "module": "esnext",
        "moduleResolution": "node",
        "target": "esnext",
        "noUnusedLocals": true,
        "noUnusedParameters": true,
        "noImplicitAny": false,
-       "allowSyntheticDefaultImports": true,
        "esModuleInterop": true,
        "experimentalDecorators": true,
-       "inlineSourceMap": true,
        "lib": [
            "esnext"
-       ],
-       "typeRoots": [
-           "./types"
        ]
-   },
-   "include": [
-       "src/index.ts"
-   ],
-   "exclude": [
-       "lib/**/*"
-   ]
+   }
 }

Don't forget to remove yarn.lock and run a yarn after.

"babel-core": "^7.0.0-0" is necessary, it's a bridge to make packages using old babel-core use the new v7 version

Having tsconfig and tsconfig.build allows your IDE to have completion in all ts files and ts-jest to be able to compile test files, while having your compiler to ignore test files for example, or use a different config. Also running a simple tsc in the project will make a type-check without emitting anything

@huafu @ahnpnl thank you guys!

If you ever land here via a search engine, I just had a comparable issue in VS Code and simply restarting the IDE solved it (actually, Developer: reload window did the trick). Hopefully this will help someone troubleshoot the issue.

@jbmusso uuugh that worked for me. thanks.

@jbmusso same here! Using Developer: Reload Window fixed my issue

Ha! Reload did it for me too. Was driving me nuts

@jbmusso thank you!

I ran in to this issue when working with Google Cloud Functions in VS Code where the folder structure was project/functions/*project root with tsconfig, package.json etc* and I opened the project in the root folder. But when I opened the project/functions folder everything worked fine. Hope this can save someone some time

@karatekaneen Awesome! Thanks. Just ran into this like 1 hour ago! But why in the world...?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Vinnl picture Vinnl  路  3Comments

Slessi picture Slessi  路  3Comments

ahnpnl picture ahnpnl  路  3Comments

stephenotalora picture stephenotalora  路  3Comments

GeeWee picture GeeWee  路  4Comments