Skip to content

implements a custom typescript config possibility in compilers/typesc… #53

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

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/compilers/typescript-compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const compileBabel = require('./babel-compiler')
const loadBabelConfig = require('../load-babel-config.js')
const cache = require('../cache')
const logger = require('../logger')
const fs = require('fs')

const defaultTypescriptConfig = {
'compilerOptions': {
Expand Down Expand Up @@ -34,7 +35,12 @@ function getTypescriptConfig () {
if (cachedConfig) {
return cachedConfig
} else {
const { config } = tsconfig.loadSync(process.cwd())
const tscPath = process.cwd()
let tscFile = 'tsconfig.jest.json'
if (!fs.existsSync(tscPath+ '/'+ tscFile)){
tscFile = false
}
const { config } = tsconfig.loadSync(tscPath, tscFile)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use a jest global to get the file name, similarly to how ts-jest does it—https://github.com/kulshekhar/ts-jest/blob/master/src/preprocessor.ts#L17

You can pass a global in in the Jest config object:

{
  "jest": {
    "globals": {
      "vue-jest": {
        "tsConfigFile": "my-tsconfig.json"
      }
    }
  }
}


if (!config) {
logger.info('no tsconfig.json found, defaulting to default typescript options')
Expand Down