mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 13:29:44 +00:00
[html] unresolved import error in embedded JavaScript (#154261)
[html] unresolved import error in embedded JavaScript #154002
This commit is contained in:
parent
585b6685dd
commit
ac74e9d093
|
@ -93,13 +93,16 @@ function getLanguageServiceHost(scriptKind: ts.ScriptKind) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ignoredErrors = [
|
||||||
|
1108, /* A_return_statement_can_only_be_used_within_a_function_body_1108 */
|
||||||
|
2792, /* Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_node_or_to_add_aliases_to_the_paths_option */
|
||||||
|
];
|
||||||
|
|
||||||
export function getJavaScriptMode(documentRegions: LanguageModelCache<HTMLDocumentRegions>, languageId: 'javascript' | 'typescript', workspace: Workspace): LanguageMode {
|
export function getJavaScriptMode(documentRegions: LanguageModelCache<HTMLDocumentRegions>, languageId: 'javascript' | 'typescript', workspace: Workspace): LanguageMode {
|
||||||
const jsDocuments = getLanguageModelCache<TextDocument>(10, 60, document => documentRegions.get(document).getEmbeddedDocument(languageId));
|
const jsDocuments = getLanguageModelCache<TextDocument>(10, 60, document => documentRegions.get(document).getEmbeddedDocument(languageId));
|
||||||
|
|
||||||
const host = getLanguageServiceHost(languageId === 'javascript' ? ts.ScriptKind.JS : ts.ScriptKind.TS);
|
const host = getLanguageServiceHost(languageId === 'javascript' ? ts.ScriptKind.JS : ts.ScriptKind.TS);
|
||||||
const globalSettings: Settings = {};
|
const globalSettings: Settings = {};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getId() {
|
getId() {
|
||||||
return languageId;
|
return languageId;
|
||||||
|
@ -110,7 +113,7 @@ export function getJavaScriptMode(documentRegions: LanguageModelCache<HTMLDocume
|
||||||
const languageService = await host.getLanguageService(jsDocument);
|
const languageService = await host.getLanguageService(jsDocument);
|
||||||
const syntaxDiagnostics: ts.Diagnostic[] = languageService.getSyntacticDiagnostics(jsDocument.uri);
|
const syntaxDiagnostics: ts.Diagnostic[] = languageService.getSyntacticDiagnostics(jsDocument.uri);
|
||||||
const semanticDiagnostics = languageService.getSemanticDiagnostics(jsDocument.uri);
|
const semanticDiagnostics = languageService.getSemanticDiagnostics(jsDocument.uri);
|
||||||
return syntaxDiagnostics.concat(semanticDiagnostics).filter(d => d.code !== 1108).map((diag: ts.Diagnostic): Diagnostic => {
|
return syntaxDiagnostics.concat(semanticDiagnostics).filter(d => !ignoredErrors.includes(d.code)).map((diag: ts.Diagnostic): Diagnostic => {
|
||||||
return {
|
return {
|
||||||
range: convertRange(jsDocument, diag),
|
range: convertRange(jsDocument, diag),
|
||||||
severity: DiagnosticSeverity.Error,
|
severity: DiagnosticSeverity.Error,
|
||||||
|
|
Loading…
Reference in a new issue