Skip to content

fix: .vue file script lang is tsx but createSourceFile as JS. so join ScriptKind. #3097

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

Merged
merged 8 commits into from
Jan 31, 2019
Merged
Changes from all commits
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
7 changes: 4 additions & 3 deletions packages/@vue/cli-plugin-typescript/lib/tslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module.exports = function lint (args = {}, api, silent) {
before: content.slice(0, script.start),
after: content.slice(script.end)
})
return script.content
return script
}
}

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