Skip to content
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

Bump default JS target for scripts in html #150240

Merged
merged 3 commits into from May 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -31,7 +31,7 @@ module.exports = function () {
queue.push(name);
};

enqueue('es6');
enqueue('es2020.full');

var result = [];
while (queue.length > 0) {
Expand Down
Expand Up @@ -24,7 +24,7 @@ export function loadLibrary(name: string) {
try {
content = readFileSync(libPath).toString();
} catch (e) {
console.log(`Unable to load library ${name} at ${libPath}: ${e.message}`);
console.log(`Unable to load library ${name} at ${libPath}`);
content = '';
}
contents[name] = content;
Expand Down
Expand Up @@ -19,7 +19,7 @@ import { getSemanticTokens, getSemanticTokenLegend } from './javascriptSemanticT
const JS_WORD_REGEX = /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g;

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, '');
const jsLanguageService = import(/* webpackChunkName: "javascriptLibs" */ './javascriptLibs').then(libs => {
Expand Down Expand Up @@ -52,7 +52,7 @@ function getLanguageServiceHost(scriptKind: ts.ScriptKind) {
};
},
getCurrentDirectory: () => '',
getDefaultLibFileName: (_options: ts.CompilerOptions) => 'es6',
getDefaultLibFileName: (_options: ts.CompilerOptions) => 'es2020.full',
readFile: (path: string, _encoding?: string | undefined): string | undefined => {
if (path === currentTextDocument.uri) {
return currentTextDocument.getText();
Expand All @@ -66,6 +66,15 @@ function getLanguageServiceHost(scriptKind: ts.ScriptKind) {
} else {
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);
Expand Down