mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 13:46:13 +00:00
Bump default JS target for scripts in html (#150240)
* Bump default JS target for scripts in html For JS/TS files, we target ES2020 by default. However in html files we're still stuck targetting es6 This change aligns the two * use es2020.full (includes dom), fix web, avoid searching in node_modules Co-authored-by: Martin Aeschlimann <martinae@microsoft.com>
This commit is contained in:
parent
9ade6a6636
commit
a6724dcc10
|
@ -31,7 +31,7 @@ module.exports = function () {
|
||||||
queue.push(name);
|
queue.push(name);
|
||||||
};
|
};
|
||||||
|
|
||||||
enqueue('es6');
|
enqueue('es2020.full');
|
||||||
|
|
||||||
var result = [];
|
var result = [];
|
||||||
while (queue.length > 0) {
|
while (queue.length > 0) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ export function loadLibrary(name: string) {
|
||||||
try {
|
try {
|
||||||
content = readFileSync(libPath).toString();
|
content = readFileSync(libPath).toString();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(`Unable to load library ${name} at ${libPath}: ${e.message}`);
|
console.log(`Unable to load library ${name} at ${libPath}`);
|
||||||
content = '';
|
content = '';
|
||||||
}
|
}
|
||||||
contents[name] = content;
|
contents[name] = content;
|
||||||
|
|
|
@ -19,7 +19,7 @@ import { getSemanticTokens, getSemanticTokenLegend } from './javascriptSemanticT
|
||||||
const JS_WORD_REGEX = /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g;
|
const JS_WORD_REGEX = /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g;
|
||||||
|
|
||||||
function getLanguageServiceHost(scriptKind: ts.ScriptKind) {
|
function getLanguageServiceHost(scriptKind: ts.ScriptKind) {
|
||||||
const compilerOptions: ts.CompilerOptions = { allowNonTsExtensions: true, allowJs: true, lib: ['lib.es6.d.ts'], target: ts.ScriptTarget.Latest, moduleResolution: ts.ModuleResolutionKind.Classic, experimentalDecorators: false };
|
const compilerOptions: ts.CompilerOptions = { allowNonTsExtensions: true, allowJs: true, lib: ['lib.es2020.full.d.ts'], target: ts.ScriptTarget.Latest, moduleResolution: ts.ModuleResolutionKind.Classic, experimentalDecorators: false };
|
||||||
|
|
||||||
let currentTextDocument = TextDocument.create('init', 'javascript', 1, '');
|
let currentTextDocument = TextDocument.create('init', 'javascript', 1, '');
|
||||||
const jsLanguageService = import(/* webpackChunkName: "javascriptLibs" */ './javascriptLibs').then(libs => {
|
const jsLanguageService = import(/* webpackChunkName: "javascriptLibs" */ './javascriptLibs').then(libs => {
|
||||||
|
@ -52,7 +52,7 @@ function getLanguageServiceHost(scriptKind: ts.ScriptKind) {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
getCurrentDirectory: () => '',
|
getCurrentDirectory: () => '',
|
||||||
getDefaultLibFileName: (_options: ts.CompilerOptions) => 'es6',
|
getDefaultLibFileName: (_options: ts.CompilerOptions) => 'es2020.full',
|
||||||
readFile: (path: string, _encoding?: string | undefined): string | undefined => {
|
readFile: (path: string, _encoding?: string | undefined): string | undefined => {
|
||||||
if (path === currentTextDocument.uri) {
|
if (path === currentTextDocument.uri) {
|
||||||
return currentTextDocument.getText();
|
return currentTextDocument.getText();
|
||||||
|
@ -66,6 +66,15 @@ function getLanguageServiceHost(scriptKind: ts.ScriptKind) {
|
||||||
} else {
|
} else {
|
||||||
return !!libs.loadLibrary(path);
|
return !!libs.loadLibrary(path);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
directoryExists: (path: string): boolean => {
|
||||||
|
// typescript tries to first find libraries in node_modules/@types and node_modules/@typescript
|
||||||
|
// there's no node_modules in our setup
|
||||||
|
if (path.startsWith('node_modules')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return ts.createLanguageService(host);
|
return ts.createLanguageService(host);
|
||||||
|
|
Loading…
Reference in a new issue