Skip to content

Commit f3fe8b3

Browse files
lihuanjihaoqunjiang
authored andcommittedJan 31, 2019
fix: fix linting of tsx script in .vue file (#3097)
1 parent 2163260 commit f3fe8b3

File tree

1 file changed

+4
-3
lines changed
  • packages/@vue/cli-plugin-typescript/lib

1 file changed

+4
-3
lines changed
 

‎packages/@vue/cli-plugin-typescript/lib/tslint.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ module.exports = function lint (args = {}, api, silent) {
4949
before: content.slice(0, script.start),
5050
after: content.slice(script.end)
5151
})
52-
return script.content
52+
return script
5353
}
5454
}
5555

@@ -61,8 +61,9 @@ module.exports = function lint (args = {}, api, silent) {
6161
const getSourceFile = program.getSourceFile
6262
program.getSourceFile = function (file, languageVersion, onError) {
6363
if (isVueFile(file)) {
64-
const script = parseTSFromVueFile(file) || ''
65-
return ts.createSourceFile(file, script, languageVersion, true)
64+
const { content, lang = 'js' } = parseTSFromVueFile(file) || { content: '', lang: 'js' }
65+
const contentLang = ts.ScriptKind[lang.toUpperCase()];
66+
return ts.createSourceFile(file, content, languageVersion, true, contentLang)
6667
} else {
6768
return getSourceFile.call(this, file, languageVersion, onError)
6869
}

0 commit comments

Comments
 (0)
Please sign in to comment.