-
-
Notifications
You must be signed in to change notification settings - Fork 593
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
Refactor component analysis #504
Conversation
export function createUpdater() { | ||
const clssf = ts.createLanguageServiceSourceFile; | ||
const ulssf = ts.updateLanguageServiceSourceFile; | ||
return { | ||
createLanguageServiceSourceFile(fileName: string, scriptSnapshot: ts.IScriptSnapshot, scriptTarget: ts.ScriptTarget, version: string, setNodeParents: boolean, scriptKind?: ts.ScriptKind): ts.SourceFile { | ||
const sourceFile = clssf(fileName, scriptSnapshot, scriptTarget, version, setNodeParents, scriptKind); | ||
if (isVue(fileName)) { | ||
// store scriptKind info on sourceFile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be the best workaround.We must to use one single languageService for both TS and JS. We cannot separate two language services to differentiate behavior. Otherwise two file types cannot interoperate with each other.
Also, createLanguageServiceSourceFile
and its update version are singletons under ts
namespace. We need to make these two function stateless. So recording scriptKind on sourceFile might be the only solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe people will do that, say, migration. Even if we can separate those two, createLanguageServiceSourceFile
is a singleton. So we cannot change the behavior according to one language service, due to that multiple services will exist.
Ping @octref This is ready to be reviewed. |
Ping @octref |
Sorry had been busy. I'll take a look tomorrow. |
34e3d88
to
0a11a7d
Compare
Thanks, have been busy over other stuff. |
0.11 is not picking up Wondering if that's caused by this PR. I'll take a look later today too. |
@octref It works as expected for me. I guess the problem is from #515 . I tested After setting it https://github.com/octref/veturpack/blob/master/tsconfig.json |
I see, so veturpack's Think we should do a popup to suggest setting this, if they
|
I don't think this would be that confusing. If the user uses We can prioritize jsconfig.json if users primarily use JavaScript. |
Oh that's a good point. I never checked that. That makes sense then. I'll add some docs to setup. |
Fix #502
This pull request also skips wrapping ts script object, so vetur and ts-loader will align.
The component analysis combines both AST traversal and type checking. More specifically, we only do type analysis on the definition object literal, e.g the argument of
Vue.extend
, which is found by AST traversal.This approach is independent of Vue's type declaration. So both Vue2.4- and 2.5+ are supported.