-
-
Notifications
You must be signed in to change notification settings - Fork 442
Understanding perf issues with syncHostData and with
#947
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
Comments
Thanks to focus on this! (The benefits of this improvement are huge, so I put this as a top priority.)
Might not be able to explain it well in words, I can provide a sequence diagram later if it helps. |
Hi @DanielRosenwasser, I'm sorry for the late reply, this problem is actually not easy to explain, after I thought about the sequence diagram, I think it's clearer with explain what actually happen. <template>
{{ | }}
</template>
<script lang="ts">
import { defineComponent } from 'vue';
export default defineComponent({
props: {
msg: String
}
});
</script> When trigger auto-complete at
const virtual_script_code = `
import { defineComponent } from 'vue';
export default defineComponent({
props: {
msg: String
}
});`;
(I know we can use typecheck API, but it can't avoid the performance issue, and I need make sure these behavior is reproducible when I wirte virtual files to system for maintainability.) const virtual_middle_code = `
import Component from './virtual_script_code';
const ctx = new Component();
ctx.`; // intentionally append `.` to do auto-complete internal later
import * as ts from 'typescript';
let projectVersion = 1;
const virtualFiles = {
'/virtual_script_code.ts': ts.ScriptSnapshot.fromString(virtual_script_code),
'/virtual_middle_file.ts': ts.ScriptSnapshot.fromString(virtual_middle_code),
};
const languageService = ts.createLanguageService({
getProjectVersion() {
return projectVersion.toString();
},
getScriptFileNames() {
return Object.keys(virtualFiles);
},
getScriptSnapshot(fileName) {
return virtualFiles[fileName];
},
// ... other options is not important for explain
});
const completions = languageService.getCompletionsAtPosition('/virtual_middle_code.ts', 82 /* offset at `ctx.|` */);
const ctx = completions.entries.map(entry => entry.name); // ['msg'] The
const virtual_template_code = `
import Component from './virtual_script_code';
const ctx = new Component();
${ctx.map(prop => `let ${prop} = ctx.${prop};`).join('\n')}
{ | }`;
/* =>
import Component from './virtual_script_code';
const ctx = new Component();
let msg = ctx.msg;
{ | }
*/
virtualFiles['./virtual_template_code.ts'] = ts.ScriptSnapshot.fromString(virtual_template_code);
projectVersion++;
const result = languageService.getCompletionsAtPosition('/virtual_template_code.ts', 100 /* offset at `|` in virtual template code */);
// ... mapping and response result to LSP We calling With
const virtual_script_code = `
import { defineComponent } from 'vue';
export default defineComponent({
props: {
msg: String
}
});`;
const virtual_template_code = `
import Component from './virtual_script_code';
const ctx = new Component();
with (ctx) {
{ | };
}`;
import * as ts from 'typescript';
let projectVersion = 1;
const virtualFiles = {
'/virtual_script_code.ts': ts.ScriptSnapshot.fromString(virtual_script_code),
'/virtual_template_code.ts': ts.ScriptSnapshot.fromString(virtual_template_code),
};
const languageService = ts.createLanguageService({
getProjectVersion() {
return projectVersion.toString();
},
getScriptFileNames() {
return Object.keys(virtualFiles);
},
getScriptSnapshot(fileName) {
return virtualFiles[fileName];
},
// ... other options is not important for explain
});
const result = languageService.getCompletionsAtPosition('/virtual_template_code.ts', 98 /* offset at `|` in virtual template code */);
// ... mapping and response result to LSP You can see we only call |
There's a discussion over at microsoft/TypeScript#41051 around why Volar is interested in TypeScript supporting
with
statements. If you're okay with having a discussion here, I think I'd like to better understand some of the architectural constraints around this - specifically why there needs to be asynchronizeHostData
step to grab the contents of a file.(Of course, please prioritize #941 over this. This can wait, I would much rather you prioritize yourself first and respect your time.)
The text was updated successfully, but these errors were encountered: