Skip to content

Commit

Permalink
fix(typescript-config): extends option in tsconfig Fixes vuejs#144
Browse files Browse the repository at this point in the history
  • Loading branch information
yohodopo committed Jan 30, 2019
1 parent 13426a0 commit 723b0fd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions lib/typescript-transformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
ensureRequire('typescript', ['typescript'])
const typescript = require('typescript')
const vueJestConfig = getVueJestConfig(config)
const { tsconfig } = getTsJestConfig(config)
const tsconfig = getTsJestConfig(config)
const babelOptions = getBabelOptions(filePath)

const res = typescript.transpileModule(scriptContent, tsconfig)
Expand All @@ -24,7 +24,10 @@ module.exports = {
// handle ES modules in TS source code in case user uses non commonjs module
// output and there is no .babelrc.
let inlineBabelOptions = {}
if (tsconfig.compilerOptions.module !== 'commonjs' && !babelOptions) {
if (
tsconfig.compilerOptions.module !== typescript.ModuleKind.CommonJS &&
!babelOptions
) {
inlineBabelOptions = {
plugins: [require('@babel/plugin-transform-modules-commonjs')]
}
Expand Down
3 changes: 2 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ const getBabelOptions = function loadBabelOptions(filename, options = {}) {

const getTsJestConfig = function getTsJestConfig(config) {
const tr = createTransformer()
return tr.configsFor(config)
const { typescript } = tr.configsFor(config)
return { compilerOptions: typescript.options }
}

function isValidTransformer(transformer) {
Expand Down

0 comments on commit 723b0fd

Please sign in to comment.