diff --git a/.github/workflows/dev-test.yml b/.github/workflows/dev-test.yml index 89131c4913b9..5dd029bbc2db 100644 --- a/.github/workflows/dev-test.yml +++ b/.github/workflows/dev-test.yml @@ -26,7 +26,8 @@ jobs: - "macos-latest" - "windows-latest" node: - - "19" + # https://github.com/nodejs/node/issues/47096 + - "19.7.0" - "18" - "16" include: @@ -38,9 +39,9 @@ jobs: CHECK_TEST_PARSERS: true exclude: - os: "macos-latest" - node: "19" + node: "19.7.0" - os: "windows-latest" - node: "19" + node: "19.7.0" env: ENABLE_CODE_COVERAGE: ${{ matrix.ENABLE_CODE_COVERAGE }} FULL_TEST: ${{ matrix.FULL_TEST }} diff --git a/.github/workflows/prod-test.yml b/.github/workflows/prod-test.yml index ef8bd9bda181..4d94c80a494c 100644 --- a/.github/workflows/prod-test.yml +++ b/.github/workflows/prod-test.yml @@ -55,7 +55,8 @@ jobs: - "macos-latest" - "windows-latest" node: - - "19" + # https://github.com/nodejs/node/issues/47096 + - "19.7.0" - "18" - "16" - "14" @@ -65,9 +66,9 @@ jobs: FULL_TEST: true exclude: - os: "macos-latest" - node: "19" + node: "19.7.0" - os: "windows-latest" - node: "19" + node: "19.7.0" - os: "macos-latest" node: "16" - os: "windows-latest" diff --git a/changelog_unreleased/typescript/14391-2.md b/changelog_unreleased/typescript/14391-2.md index 0a026fadc824..d99d1faf00e0 100644 --- a/changelog_unreleased/typescript/14391-2.md +++ b/changelog_unreleased/typescript/14391-2.md @@ -1,4 +1,4 @@ -#### Support TypeScript 5.0 via `babel-ts` parser (#14391 by @fisker) +#### Support TypeScript 5.0 (#14391 by @fisker, #13819 by @fisker, @sosukesuzuki) TypeScript 5.0 introduces two new syntactic features: diff --git a/cspell.json b/cspell.json index de02b4c99981..c29d0af75492 100644 --- a/cspell.json +++ b/cspell.json @@ -328,6 +328,7 @@ "Tradeshift", "Transloadit", "trippable", + "tsbuild", "tsep", "TSES", "TSJS", diff --git a/package.json b/package.json index e96022c5f833..fe75fda02541 100644 --- a/package.json +++ b/package.json @@ -38,8 +38,8 @@ "@iarna/toml": "2.2.5", "@prettier/is-es5-identifier-name": "0.1.0", "@prettier/parse-srcset": "2.0.2", - "@typescript-eslint/typescript-estree": "5.54.1", - "@typescript-eslint/visitor-keys": "5.54.1", + "@typescript-eslint/typescript-estree": "5.55.0", + "@typescript-eslint/visitor-keys": "5.55.0", "acorn": "8.8.2", "acorn-jsx": "5.3.2", "angular-estree-parser": "6.0.0", @@ -97,7 +97,7 @@ "string-width": "5.0.1", "strip-ansi": "7.0.1", "to-fast-properties": "4.0.0", - "typescript": "4.9.5", + "typescript": "5.0.1-rc", "unicode-regex": "3.0.0", "unified": "9.2.2", "vnopts": "1.0.2", @@ -112,7 +112,7 @@ "@types/file-entry-cache": "5.0.2", "@types/find-cache-dir": "3.2.1", "@types/jest": "29.4.0", - "@typescript-eslint/eslint-plugin": "5.54.1", + "@typescript-eslint/eslint-plugin": "5.55.0", "benchmark": "2.1.4", "browserslist-to-esbuild": "1.2.0", "c8": "7.13.0", diff --git a/scripts/build/modify-typescript-module.mjs b/scripts/build/modify-typescript-module.mjs index 8a1e29934c43..5ab60a80f0b3 100644 --- a/scripts/build/modify-typescript-module.mjs +++ b/scripts/build/modify-typescript-module.mjs @@ -4,89 +4,82 @@ import { outdent } from "outdent"; import MagicString from "magic-string"; import { writeFile, PROJECT_ROOT } from "../utils/index.mjs"; -/* -Root submodule in `typescript.js` are bundled like - -```js -var ts; -(function (ts) { - // Submodule -})(ts || (ts = {})); -``` -*/ - -const SUBMODULE_START = escapeStringRegexp("var ts;\n(function (ts) {"); -const SUBMODULE_END = escapeStringRegexp("})(ts || (ts = {}));"); - -function getSubmodules(text) { - const regexp = new RegExp( - [ - "(?<=\n)", - `(?${SUBMODULE_START})`, - "(?=\n)", - "(?.*?)", - "(?<=\n)", - `(?${SUBMODULE_END})`, - "(?=\n)", - ].join(""), - "gsu" - ); +function* getModules(text) { + const parts = text.split(/(?<=\n)( {2}\/\/ src\/\S+\n)/); + + let start = parts[0].length; + + for (let partIndex = 1; partIndex < parts.length - 1; partIndex += 2) { + const comment = parts[partIndex]; + const code = parts[partIndex + 1]; + + const path = comment.slice(" // ".length, -1); + const end = start + comment.length + code.length; + + if (/\S/.test(code)) { + const esmRegExp = new RegExp( + [ + "\\s*var (?\\w+) = __esm\\({", + `\\s*"${escapeStringRegexp(path)}"\\(\\) {`, + ".*", + "\\s*}", + "\\s*}\\);", + ].join("\\n"), + "s" + ); + const match = code.match(esmRegExp); + + yield { + isEntry: path === "src/typescript/typescript.ts", + path, + start: start + comment.length, + end: end - 1, + code, + esmModuleInitFunctionName: match?.groups.initFunctionName, + }; + } - return [...text.matchAll(regexp)].map((match) => ({ - start: match.index, - end: match.index + match[0].length, - ...match.groups, - })); + start = end; + } } class TypeScriptModuleSource { #source; - #modules; + modules; constructor(text) { this.#source = new MagicString(text); - this.#modules = getSubmodules(text); + this.modules = [...getModules(text)]; } - removeSubmodule(testFunction) { - return this.replaceSubmodule(testFunction, ""); - } - - replaceSubmodule(testFunction, replacement) { - const modules = this.#modules.filter(({ text }) => testFunction(text)); - if (modules.length !== 1) { - throw Object.assign( - new Error( - `Expect exactly one submodule to be found, got ${modules.length} submodules.` - ), - { modules } - ); + replaceModule(module, replacement) { + if (typeof module === "string") { + module = this.modules.find((searching) => searching.path === module); } - const [{ start, end, before, after }] = modules; - if (!replacement) { - this.#source.remove(start, end); - } else { - this.#source.overwrite( - start, - end, - before + "\n" + replacement + "\n" + after - ); + if (!module) { + throw Object.assign(new Error("Module not found"), { module }); } + + const { esmModuleInitFunctionName } = module; + const moduleInitCode = esmModuleInitFunctionName + ? `var ${esmModuleInitFunctionName} = () => {};` + : ""; + + this.#source.overwrite( + module.start, + module.end, + moduleInitCode + replacement + ); return this; } - removeMultipleSubmodules(testFunction) { - const modules = this.#modules.filter(({ text }) => testFunction(text)); - - if (modules.length < 2) { - throw new Error("Expect more than one submodules to be found"); + removeModule(module) { + if (typeof module === "string") { + module = this.modules.find((searching) => searching.path === module); } - for (const { start, end } of modules) { - this.#source.remove(start, end); - } - return this; + return this.replaceModule(module, ""); } replaceAlignedCode({ start, end, replacement = "" }) { @@ -113,6 +106,11 @@ class TypeScriptModuleSource { return this; } + prepend(...args) { + this.#source.prepend(...args); + return this; + } + append(...args) { this.#source.append(...args); return this; @@ -131,7 +129,7 @@ class TypeScriptModuleSource { applyChanges() { const text = this.#source.toString(); this.#source = new MagicString(text); - this.#modules = getSubmodules(text); + this.modules = getModules(text); } toString() { @@ -139,439 +137,156 @@ class TypeScriptModuleSource { } } -function modifyTypescriptModule(text) { - const source = new TypeScriptModuleSource(text); +function unwrap(text) { + const startMark = "var ts = (() => {"; + const endMark = "return require_typescript();"; + const start = text.indexOf(startMark); + const end = text.lastIndexOf(endMark); - // Code after `globalThis` shim are useless - const positionOfGlobalThisShim = text.indexOf( - "// We polyfill `globalThis` here so re can reliably patch the global scope" - ); - if (positionOfGlobalThisShim === -1) { - throw new Error("Unexpected source."); + if (start === -1 || end === -1) { + throw new Error("Unexpected source"); } - source.remove(positionOfGlobalThisShim, text.length); - source.append("module.exports = ts;"); - - // File system - source.removeSubmodule((text) => - text.includes("ts.generateDjb2Hash = generateDjb2Hash;") - ); - - // Language service - source.removeSubmodule((text) => - text.includes("ts.TypeScriptServicesFactory = TypeScriptServicesFactory;") - ); - source - .replaceAlignedCode({ - start: "function createLanguageService(", - end: "}", - }) - .replace("ts.createLanguageService = createLanguageService;", ""); - - // `ts.scanner` - // This is a big module, most code except `ts.scanner` is not used - source.replaceSubmodule( - (text) => text.includes("ts.findPackageJson = findPackageJson;"), - "ts.scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true);" - ); - - // `ts.visitNode` - source.removeSubmodule((text) => text.includes("ts.visitNode = visitNode;")); - - // `ts.createGetSymbolWalker` - source.removeSubmodule((text) => - text.includes("ts.createGetSymbolWalker = createGetSymbolWalker;") - ); - - // `ts.getModuleInstanceState ` - source.removeSubmodule((text) => - text.includes("ts.getModuleInstanceState = getModuleInstanceState;") - ); - - /* spell-checker: disable */ - // `ts.createParenthesizerRules` - source - .replaceAlignedCode({ - start: "function createParenthesizerRules(", - end: "}", - }) - .replace( - "ts.createParenthesizerRules = createParenthesizerRules;", - "ts.createParenthesizerRules = () => ts.nullParenthesizerRules;" - ); - /* spell-checker: enable */ - - // `ts.createNodeConverters` - source - .replaceAlignedCode({ - start: "function createNodeConverters(", - end: "}", - }) - .replace( - "ts.createNodeConverters = createNodeConverters;", - "ts.createNodeConverters = () => ts.nullNodeConverters;" - ); - - // `ts.classifier` - source.removeSubmodule((text) => text.includes("classifier = ts.classifier")); - source.removeSubmodule((text) => - text.includes("ts.createClassifier = createClassifier;") - ); - - // `ts.getScriptTargetFeatures` - source - .replaceAlignedCode({ - start: "function getScriptTargetFeatures(", - end: "}", - }) - .replace("ts.getScriptTargetFeatures = getScriptTargetFeatures;", ""); - - // `ts.Version` - source.removeSubmodule((text) => text.includes("ts.Version = Version;")); - - // `ts.transform` - source.removeSubmodule((text) => text.includes("ts.transform = transform;")); - source.removeSubmodule((text) => - text.includes("ts.getOrCreateEmitNode = getOrCreateEmitNode;") - ); - source.removeSubmodule((text) => - text.includes("ts.createEmitHelperFactory = createEmitHelperFactory;") - ); - - // `ts.BreakpointResolver` - source.removeSubmodule((text) => - text.trimStart().startsWith("var BreakpointResolver;") - ); - - // `ts.textChanges` - source.removeSubmodule((text) => - text.trimStart().startsWith("var textChanges;") - ); - - // `ts.preProcessFile` - source.removeSubmodule((text) => - text.includes("ts.preProcessFile = preProcessFile;") - ); - - // `ts.Rename` - source.removeSubmodule((text) => text.trimStart().startsWith("var Rename;")); - - // `ts.SmartSelectionRange` - source.removeSubmodule((text) => - text.trimStart().startsWith("var SmartSelectionRange;") - ); - - // `ts.SignatureHelp` - source.removeSubmodule((text) => - text.trimStart().startsWith("var SignatureHelp;") - ); - - // `ts.InlayHints` - source.removeSubmodule((text) => - text.trimStart().startsWith("var InlayHints;") - ); - - // Sourcemap - source - .removeSubmodule((text) => - text.includes("ts.getSourceMapper = getSourceMapper;") - ) - .removeSubmodule((text) => - text.includes("ts.createSourceMapGenerator = createSourceMapGenerator;") - ); - // Suggestion - source.removeSubmodule((text) => - text.includes( - "ts.computeSuggestionDiagnostics = computeSuggestionDiagnostics;" - ) - ); - - // Tracing - source.removeSubmodule((text) => - text.includes("ts.startTracing = tracingEnabled.startTracing;") - ); - - // Diagnostics - source.removeSubmodule((text) => - text.includes("ts.createProgramHost = createProgramHost;") - ); - - // `ts.transformTypeScript` - source.removeSubmodule((text) => - text.includes("ts.transformTypeScript = transformTypeScript;") - ); - - // `ts.createRuntimeTypeSerializer` - source.removeSubmodule((text) => - text.includes( - "ts.createRuntimeTypeSerializer = createRuntimeTypeSerializer;" - ) - ); - - // Transform - source - // `ts.transformLegacyDecorators` - .removeSubmodule((text) => - text.includes("ts.transformLegacyDecorators = transformLegacyDecorators;") - ) - // `ts.transformES5` - .removeSubmodule((text) => text.includes("ts.transformES5 = transformES5;")) - // `ts.transformES2015` - .removeSubmodule((text) => - text.includes("ts.transformES2015 = transformES2015;") - ) - // `ts.transformES2016` - .removeSubmodule((text) => - text.includes("ts.transformES2016 = transformES2016;") - ) - // `ts.transformES2017` & `ts.createSuperAccessVariableStatement` - .removeSubmodule( - (text) => - text.includes("ts.transformES2017 = transformES2017;") && - text.includes( - "ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement;" - ) - ) - // `ts.transformES2018` - .removeSubmodule((text) => - text.includes("ts.transformES2018 = transformES2018;") - ) - // `ts.transformES2019` - .removeSubmodule((text) => - text.includes("ts.transformES2019 = transformES2019;") - ) - // `ts.transformES2020` - .removeSubmodule((text) => - text.includes("ts.transformES2020 = transformES2020;") - ) - // `ts.transformES2021` - .removeSubmodule((text) => - text.includes("ts.transformES2021 = transformES2021;") - ) - // `ts.transformESNext` - .removeSubmodule((text) => - text.includes("ts.transformESNext = transformESNext;") - ) - // `ts.transformJsx` - .removeSubmodule((text) => text.includes("ts.transformJsx = transformJsx;")) - // `ts.transformGenerators` - .removeSubmodule((text) => - text.includes("ts.transformGenerators = transformGenerators;") - ) - // `ts.transformModule` - .removeSubmodule((text) => - text.includes("ts.transformModule = transformModule;") - ) - // `ts.transformSystemModule` - .removeSubmodule((text) => - text.includes("ts.transformSystemModule = transformSystemModule;") - ) - // `ts.transformECMAScriptModule` - .removeSubmodule((text) => - text.includes("ts.transformECMAScriptModule = transformECMAScriptModule;") - ) - // `ts.transformNodeModule` - .removeSubmodule((text) => - text.includes("ts.transformNodeModule = transformNodeModule;") - ) - // `ts.transformClassFields` - .removeSubmodule((text) => - text.includes("ts.transformClassFields = transformClassFields;") - ) - // `ts.transformDeclarations` - .removeSubmodule((text) => - text.includes("ts.transformDeclarations = transformDeclarations;") - ); + return text.slice(start + startMark.length, end); +} - // `ts.transformNodes` and more - source.removeSubmodule((text) => - text.includes("ts.transformNodes = transformNodes;") - ); +function modifyTypescriptModule(text) { + text = unwrap(text); - // `ts.server` - source.removeSubmodule((text) => text.includes("(ts.server = {})")); + const source = new TypeScriptModuleSource(text); - // `ts.JsTyping` - source.removeSubmodule((text) => text.includes("(ts.JsTyping = {})")); + // Deprecated + for (const module of source.modules) { + if (module.path.startsWith("src/deprecatedCompat/")) { + source.removeModule(module); + } + } - // `ts.ClassificationType` - source.removeSubmodule((text) => - text.includes("(ts.ClassificationType = {})") - ); + // jsTyping + for (const module of source.modules) { + if (module.path.startsWith("src/jsTyping/")) { + source.removeModule(module); + } + } - // Build - source - .removeSubmodule((text) => - text.includes("ts.createSolutionBuilder = createSolutionBuilder;") - ) - .removeSubmodule((text) => - text.includes("ts.parseBuildCommand = parseBuildCommand;") - ) - .removeSubmodule((text) => - text.includes("ts.createBuilderProgram = createBuilderProgram;") - ) - .removeSubmodule((text) => - text.includes( - "ts.createSemanticDiagnosticsBuilderProgram = createSemanticDiagnosticsBuilderProgram;" - ) - ) - .removeSubmodule((text) => - text.includes("ts.createResolutionCache = createResolutionCache;") - ) - .removeSubmodule((text) => - text.includes("ts.createWatchCompilerHost = createWatchCompilerHost;") - ) - .removeSubmodule((text) => - text.includes( - "ts.resolveConfigFileProjectName = resolveConfigFileProjectName;" - ) - ) - .removeSubmodule((text) => - text.includes("ts.getBuildInfo = getBuildInfo;") - ); + // services + for (const module of source.modules) { + if ( + module.path === "src/services/services.ts" || + module.path === "src/services/_namespaces/ts.ts" + ) { + continue; + } - // Compile - source - .removeSubmodule((text) => - text.includes("ts.createCompilerHost = createCompilerHost;") - ) - .removeSubmodule((text) => text.includes("(ts.BuilderState = {})")) - .removeSubmodule((text) => text.includes("ts.transpile = transpile;")); - - // Watch - source.removeSubmodule((text) => - text.includes("ts.getWatchFactory = getWatchFactory;") - ); + // This is a big module, most code except `scanner` is not used + if (module.path === "src/services/utilities.ts") { + source.replaceModule( + module, + outdent` + var scanner; + var ${module.esmModuleInitFunctionName} = () => { + init_debug(); + scanner = createScanner(99 /* Latest */, /*skipTrivia*/ true); + }; + ` + ); + continue; + } - // `import`/`export` cache - source.removeSubmodule((text) => - text.includes( - /* cspell:disable-next-line */ - "ts.createCacheableExportInfoMap = createCacheableExportInfoMap;" - ) - ); + if (module.path.startsWith("src/services/")) { + source.removeModule(module); + } + } - // `ts.canProduceDiagnostics`, `ts.createGetSymbolAccessibilityDiagnosticForNode`, and `ts.createGetSymbolAccessibilityDiagnosticForNode` - source.removeSubmodule((text) => - text.includes("ts.canProduceDiagnostics = canProduceDiagnostics;") - ); + // `transformers` + source.removeModule("src/compiler/transformer.ts"); + for (const module of source.modules) { + if (module.path.startsWith("src/compiler/transformers/")) { + source.removeModule(module); + } + } // `ts.moduleSpecifiers` - source.removeSubmodule((text) => text.includes("(ts.moduleSpecifiers = {})")); - - // `ts.trace` - source.removeSubmodule((text) => text.includes("ts.trace = trace;")); - - // `ts.createTypeChecker` - source.removeSubmodule((text) => - text.includes("ts.createTypeChecker = createTypeChecker;") - ); - - // `ts.DocumentHighlights` - source.removeSubmodule((text) => - text.includes("(ts.DocumentHighlights = {})") - ); - - // `ts.createDocumentRegistry` - source.removeSubmodule((text) => - text.includes("ts.createDocumentRegistry = createDocumentRegistry;") - ); - - // `ts.CallHierarchy` - source.removeSubmodule((text) => text.includes("(ts.CallHierarchy = {})")); - - // `ts.flattenDestructuringAssignment` and `ts.flattenDestructuringBinding` - source.removeSubmodule( - (text) => - text.includes( - "ts.flattenDestructuringAssignment = flattenDestructuringAssignment" - ) && - text.includes( - "ts.flattenDestructuringBinding = flattenDestructuringBinding" - ) - ); - - // `ts.processTaggedTemplateExpression` - source.removeSubmodule((text) => - text.includes( - "ts.processTaggedTemplateExpression = processTaggedTemplateExpression" - ) - ); - - // Editor - source - .removeSubmodule((text) => - text.includes("ts.getEditsForFileRename = getEditsForFileRename;") - ) - .removeSubmodule((text) => text.includes("(ts.GoToDefinition = {})")) - .removeSubmodule((text) => text.includes("(ts.JsDoc = {})")) - .removeSubmodule((text) => text.includes("(ts.NavigateTo = {})")) - .removeSubmodule((text) => text.includes("(ts.NavigationBar = {})")) - .removeSubmodule((text) => text.includes("(ts.OrganizeImports = {})")) - .removeSubmodule((text) => - text.includes("(ts.OutliningElementsCollector = {})") - ) - .removeSubmodule((text) => - text.includes("ts.createPatternMatcher = createPatternMatcher;") - ) - .removeSubmodule((text) => text.includes("(ts.SymbolDisplay = {})")); - - // `ts.refactor` (multiple) - source.removeMultipleSubmodules((text) => - text.trimStart().startsWith("var refactor;") - ); + source.removeModule("src/compiler/_namespaces/ts.moduleSpecifiers.ts"); + source.removeModule("src/compiler/moduleSpecifiers.ts"); - // `ts.codefix` (multiple) - source.removeMultipleSubmodules((text) => - text.trimStart().startsWith("var codefix;") - ); + // Sourcemap + source.removeModule("src/compiler/sourcemap.ts"); + + // watch + source.removeModule("src/compiler/watch.ts"); + source.removeModule("src/compiler/watchPublic.ts"); + source.removeModule("src/compiler/watchUtilities.ts"); + + // build + source.removeModule("src/compiler/commandLineParser.ts"); + source.removeModule("src/compiler/builder.ts"); + source.removeModule("src/compiler/builderPublic.ts"); + source.removeModule("src/compiler/resolutionCache.ts"); + source.removeModule("src/compiler/tsbuild.ts"); + source.removeModule("src/compiler/tsbuildPublic.ts"); + source.removeModule("src/compiler/builderState.ts"); + source.removeModule("src/compiler/builderStatePublic.ts"); + + // Misc + source.removeModule("src/compiler/symbolWalker.ts"); + source.removeModule("src/compiler/binder.ts"); + source.removeModule("src/compiler/semver.ts"); + source.removeModule("src/compiler/program.ts"); + source.removeModule("src/compiler/moduleNameResolver.ts"); + source.removeModule("src/compiler/checker.ts"); + source.removeModule("src/compiler/visitorPublic.ts"); + source.removeModule("src/compiler/emitter.ts"); + source.removeModule("src/compiler/_namespaces/ts.performance.ts"); - // `ts.formatting` (multiple) - source.removeMultipleSubmodules((text) => - text.trimStart().startsWith("var formatting;") - ); + // File system + source.replaceModule("src/compiler/sys.ts", "var sys;"); + source.replaceModule("src/compiler/tracing.ts", "var tracing;"); - // `ts.Completions` (multiple) - source.removeMultipleSubmodules((text) => - text.trimStart().startsWith("var Completions;") + // perfLogger + source.replaceModule( + "src/compiler/perfLogger.ts", + "var perfLogger = new Proxy(() => {}, {get: () => perfLogger});" ); - // `ts.FindAllReferences` (multiple) - source.removeMultipleSubmodules((text) => - text.trimStart().startsWith("var FindAllReferences;") + // performanceCore + source.replaceModule( + "src/compiler/performanceCore.ts", + outdent` + var tryGetNativePerformanceHooks = () => {}; + var timestamp = Date.now; + ` ); - // Performance - source.replaceSubmodule( - (text) => - text.includes( - "ts.tryGetNativePerformanceHooks = tryGetNativePerformanceHooks;" - ), + // `factory` + source.removeModule("src/compiler/factory/emitNode.ts"); + source.removeModule("src/compiler/factory/emitHelpers.ts"); + source.replaceModule( + "src/compiler/factory/nodeConverters.ts", outdent` - ts.tryGetNativePerformanceHooks = () => {}; - ts.timestamp = Date.now; + var createNodeConverters = () => new Proxy({}, {get: () => () => {}}); ` ); + /* spell-checker: disable */ + // `ts.createParenthesizerRules` source.replaceAlignedCode({ - start: "var debugObjectHost = (function () {", - end: "})();", + start: "function createParenthesizerRules(", + end: "}", }); + /* spell-checker: enable */ - // TODO[@fisker]: investigate possible `magic-string` bug - source.applyChanges(); + source.replaceAlignedCode({ + start: "function getScriptTargetFeatures(", + end: "}", + }); - for (const [find, replacement] of Object.entries({ - // yarn pnp - "process.versions.pnp": "undefined", + source.replaceAlignedCode({ + start: "var __require = ", + end: "});", + }); - // Dynamic `require()`s - "ts.sys && ts.sys.require": "false", - "require(etwModulePath)": "undefined", - })) { - source.replaceAll(find, replacement); - } + source.append("module.exports = require_typescript();"); return source.toString(); } diff --git a/src/language-js/parse/postprocess/typescript.js b/src/language-js/parse/postprocess/typescript.js index 4b523a4e1606..82ca62b9656a 100644 --- a/src/language-js/parse/postprocess/typescript.js +++ b/src/language-js/parse/postprocess/typescript.js @@ -23,20 +23,6 @@ function throwErrorOnTsNode(node, message) { throwTsSyntaxError({ loc: getTsNodeLocation(node) }, message); } -// Invalid decorators are removed since `@typescript-eslint/typescript-estree` v4 -// https://github.com/typescript-eslint/typescript-eslint/pull/2375 -// There is a `checkGrammarDecorators` in `typescript` package, consider use it directly in future -function throwErrorForInvalidDecorator(tsNode) { - const { illegalDecorators } = tsNode; - if (!isNonEmptyArray(illegalDecorators)) { - return; - } - - const [{ expression }] = illegalDecorators; - - throwErrorOnTsNode(expression, "Decorators are not valid here."); -} - // Values of abstract property is removed since `@typescript-eslint/typescript-estree` v5 // https://github.com/typescript-eslint/typescript-eslint/releases/tag/v5.0.0 function throwErrorForInvalidAbstractProperty(tsNode, esTreeNode) { @@ -70,7 +56,49 @@ function throwErrorForInvalidModifier(node) { for (const modifier of modifiers) { if (ts.isDecorator(modifier)) { - continue; + const legacyDecorators = true; + if ( + // @ts-expect-error -- internal? + !ts.nodeCanBeDecorated( + legacyDecorators, + node, + node.parent, + node.parent.parent + ) + ) { + if ( + node.kind === SyntaxKind.MethodDeclaration && + // @ts-expect-error -- internal? + !ts.nodeIsPresent(node.body) + ) { + throwErrorOnTsNode( + modifier, + "A decorator can only decorate a method implementation, not an overload." + ); + } else { + throwErrorOnTsNode(modifier, "Decorators are not valid here."); + } + } else if ( + legacyDecorators && + (node.kind === SyntaxKind.GetAccessor || + node.kind === SyntaxKind.SetAccessor) + ) { + // @ts-expect-error -- internal? + const accessors = ts.getAllAccessorDeclarations( + node.parent.members, + node + ); + if ( + // @ts-expect-error -- internal? + ts.hasDecorators(accessors.firstAccessor) && + node === accessors.secondAccessor + ) { + throwErrorOnTsNode( + modifier, + "Decorators cannot be applied to multiple get/set accessors of the same name." + ); + } + } } if (modifier.kind !== SyntaxKind.ReadonlyKeyword) { @@ -302,7 +330,6 @@ function throwErrorForInvalidNodes(tsParseResult, text) { return; } - throwErrorForInvalidDecorator(tsNode); throwErrorForInvalidAbstractProperty(tsNode, esTreeNode); throwErrorForInvalidModifier(tsNode); }); diff --git a/src/language-js/print/class.js b/src/language-js/print/class.js index 1bf386656c17..a84259634da8 100644 --- a/src/language-js/print/class.js +++ b/src/language-js/print/class.js @@ -301,11 +301,7 @@ function shouldPrintSemicolonAfterClassProperty(node, nextNode) { if ( !node.computed && type === "Identifier" && - (name === "static" || - name === "get" || - name === "set" || - // TODO: Remove this https://github.com/microsoft/TypeScript/issues/51707 is fixed - name === "accessor") && + (name === "static" || name === "get" || name === "set") && !node.value && !node.typeAnnotation ) { diff --git a/tests/format/js/decorators/class-expression/__snapshots__/jsfmt.spec.js.snap b/tests/format/js/decorators/class-expression/__snapshots__/jsfmt.spec.js.snap index 447b6b7af721..1d6f6ab4ebf8 100644 --- a/tests/format/js/decorators/class-expression/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/js/decorators/class-expression/__snapshots__/jsfmt.spec.js.snap @@ -25,9 +25,9 @@ exports[`arguments.js [flow] format 1`] = ` `; exports[`arguments.js [typescript] format 1`] = ` -"Argument expression expected. (1:13) +"Decorators are not valid here. (1:13) > 1 | console.log(@deco class Foo {}) - | ^ + | ^^^^^ 2 | console.log(@deco class {}) 3 |" `; @@ -57,9 +57,9 @@ exports[`arguments.js - {"semi":false} [flow] format 1`] = ` `; exports[`arguments.js - {"semi":false} [typescript] format 1`] = ` -"Argument expression expected. (1:13) +"Decorators are not valid here. (1:13) > 1 | console.log(@deco class Foo {}) - | ^ + | ^^^^^ 2 | console.log(@deco class {}) 3 |" `; @@ -137,9 +137,9 @@ exports[`class-expression.js [flow] format 1`] = ` `; exports[`class-expression.js [typescript] format 1`] = ` -"Expression expected. (1:13) +"Decorators are not valid here. (1:13) > 1 | const a1 = (@deco class Foo {}); - | ^ + | ^^^^^ 2 | const a2 = (@deco class {}); 3 | 4 | (@deco class Foo {});" @@ -173,9 +173,9 @@ exports[`class-expression.js - {"semi":false} [flow] format 1`] = ` `; exports[`class-expression.js - {"semi":false} [typescript] format 1`] = ` -"Expression expected. (1:13) +"Decorators are not valid here. (1:13) > 1 | const a1 = (@deco class Foo {}); - | ^ + | ^^^^^ 2 | const a2 = (@deco class {}); 3 | 4 | (@deco class Foo {});" @@ -321,9 +321,9 @@ exports[`member-expression.js [flow] format 1`] = ` `; exports[`member-expression.js [typescript] format 1`] = ` -"Expression expected. (1:2) +"Decorators are not valid here. (1:2) > 1 | (@deco class Foo {}).name; - | ^ + | ^^^^^ 2 | (@deco class {}).name; 3 |" `; @@ -353,9 +353,9 @@ exports[`member-expression.js - {"semi":false} [flow] format 1`] = ` `; exports[`member-expression.js - {"semi":false} [typescript] format 1`] = ` -"Expression expected. (1:2) +"Decorators are not valid here. (1:2) > 1 | (@deco class Foo {}).name; - | ^ + | ^^^^^ 2 | (@deco class {}).name; 3 |" `; @@ -433,9 +433,9 @@ exports[`super-class.js [flow] format 1`] = ` `; exports[`super-class.js [typescript] format 1`] = ` -"Expression expected. (1:20) +"Decorators are not valid here. (1:20) > 1 | class Foo extends (@deco class Foo {}){} - | ^ + | ^^^^^ 2 | 3 | class Foo extends (@deco class {}){} 4 |" @@ -469,9 +469,9 @@ exports[`super-class.js - {"semi":false} [flow] format 1`] = ` `; exports[`super-class.js - {"semi":false} [typescript] format 1`] = ` -"Expression expected. (1:20) +"Decorators are not valid here. (1:20) > 1 | class Foo extends (@deco class Foo {}){} - | ^ + | ^^^^^ 2 | 3 | class Foo extends (@deco class {}){} 4 |" diff --git a/tests/format/js/ignore/__snapshots__/jsfmt.spec.js.snap b/tests/format/js/ignore/__snapshots__/jsfmt.spec.js.snap index 3d951117596d..ce0ea43a6ae2 100644 --- a/tests/format/js/ignore/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/js/ignore/__snapshots__/jsfmt.spec.js.snap @@ -34,11 +34,11 @@ exports[`class-expression-decorator.js [flow] format 1`] = ` `; exports[`class-expression-decorator.js [typescript] format 1`] = ` -"Expression expected. (3:3) +"Decorators are not valid here. (3:3) 1 | ( 2 | // prettier-ignore > 3 | @decorator - | ^ + | ^^^^^^^^^^ 4 | class {} 5 | ); 6 |" diff --git a/tests/format/misc/errors/invalid-typescript-decorators/__snapshots__/jsfmt.spec.js.snap b/tests/format/misc/errors/invalid-typescript-decorators/__snapshots__/jsfmt.spec.js.snap index 26d9fed0966b..1c59eee4d330 100644 --- a/tests/format/misc/errors/invalid-typescript-decorators/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/misc/errors/invalid-typescript-decorators/__snapshots__/jsfmt.spec.js.snap @@ -10,11 +10,11 @@ exports[`decorator.ts [babel-ts] format 1`] = ` `; exports[`decorator.ts [typescript] format 1`] = ` -"Decorators are not valid here. (3:2) +"Decorators are not valid here. (3:1) 1 | declare function dec(target: T): T; 2 | > 3 | @dec - | ^^^ + | ^^^^ 4 | enum E {} 5 |" `; @@ -31,11 +31,11 @@ exports[`enums.ts [babel-ts] format 1`] = ` `; exports[`enums.ts [typescript] format 1`] = ` -"Decorators are not valid here. (3:2) +"Decorators are not valid here. (3:1) 1 | // https://github.com/typescript-eslint/typescript-eslint/pull/2375 2 | > 3 | @decorator() - | ^^^^^^^^^^^ + | ^^^^^^^^^^^^ 4 | enum Direction { 5 | Up = 1, 6 | Down," @@ -51,11 +51,11 @@ exports[`function.ts [babel-ts] format 1`] = ` `; exports[`function.ts [typescript] format 1`] = ` -"Decorators are not valid here. (3:2) +"Decorators are not valid here. (3:1) 1 | // https://github.com/typescript-eslint/typescript-eslint/pull/2375 2 | > 3 | @decorator() - | ^^^^^^^^^^^ + | ^^^^^^^^^^^^ 4 | function foo( ){} 5 |" `; @@ -71,11 +71,11 @@ exports[`interface.ts [babel-ts] format 1`] = ` `; exports[`interface.ts [typescript] format 1`] = ` -"Decorators are not valid here. (4:2) +"Decorators are not valid here. (4:1) 2 | // #4632 3 | > 4 | @hello() - | ^^^^^^^ + | ^^^^^^^^ 5 | interface MyInterface {id: string; 6 | } 7 |" @@ -91,9 +91,9 @@ exports[`issue-9102.ts [babel-ts] format 1`] = ` `; exports[`issue-9102.ts [typescript] format 1`] = ` -"Decorators are not valid here. (1:2) +"Decorators are not valid here. (1:1) > 1 | @Decorator() - | ^^^^^^^^^^^ + | ^^^^^^^^^^^^ 2 | type T = 1; 3 | class C {} 4 |" diff --git a/tests/format/misc/typescript-only/__snapshots__/jsfmt.spec.js.snap b/tests/format/misc/typescript-only/__snapshots__/jsfmt.spec.js.snap index e2ffd92b523d..b58d035e7376 100644 --- a/tests/format/misc/typescript-only/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/misc/typescript-only/__snapshots__/jsfmt.spec.js.snap @@ -103,47 +103,6 @@ await 0; ================================================================================ `; -exports[`decorator-auto-accessor-like-property-name.ts - {"semi":false} format 1`] = ` -====================================options===================================== -parsers: ["typescript"] -printWidth: 80 -semi: false - | printWidth -=====================================input====================================== -class C { - accessor; - bar; -} - -=====================================output===================================== -class C { - accessor; - bar -} - -================================================================================ -`; - -exports[`decorator-auto-accessor-like-property-name.ts format 1`] = ` -====================================options===================================== -parsers: ["typescript"] -printWidth: 80 - | printWidth -=====================================input====================================== -class C { - accessor; - bar; -} - -=====================================output===================================== -class C { - accessor; - bar; -} - -================================================================================ -`; - exports[`decorator-auto-accessors-abstract-class.ts - {"semi":false} format 1`] = ` ====================================options===================================== parsers: ["typescript"] @@ -331,81 +290,6 @@ abstract class Foo { ================================================================================ `; -exports[`decorator-auto-accessors-new-line.ts - {"semi":false} format 1`] = ` -====================================options===================================== -parsers: ["typescript"] -printWidth: 80 -semi: false - | printWidth -=====================================input====================================== -class Foo { - accessor - ["bar"]; -} - -class Foo { - static accessor - bar; -} - -class Foo { - accessor - bar; -} - -=====================================output===================================== -class Foo { - accessor ["bar"] -} - -class Foo { - static accessor bar -} - -class Foo { - accessor bar -} - -================================================================================ -`; - -exports[`decorator-auto-accessors-new-line.ts format 1`] = ` -====================================options===================================== -parsers: ["typescript"] -printWidth: 80 - | printWidth -=====================================input====================================== -class Foo { - accessor - ["bar"]; -} - -class Foo { - static accessor - bar; -} - -class Foo { - accessor - bar; -} - -=====================================output===================================== -class Foo { - accessor ["bar"]; -} - -class Foo { - static accessor bar; -} - -class Foo { - accessor bar; -} - -================================================================================ -`; - exports[`parenthesized-decorators-call-expression.ts - {"semi":false} format 1`] = ` ====================================options===================================== parsers: ["typescript"] diff --git a/tests/format/typescript/decorator-auto-accessors/__snapshots__/jsfmt.spec.js.snap b/tests/format/typescript/decorator-auto-accessors/__snapshots__/jsfmt.spec.js.snap index 2b9e43887b0c..b87c7158c5f7 100644 --- a/tests/format/typescript/decorator-auto-accessors/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/typescript/decorator-auto-accessors/__snapshots__/jsfmt.spec.js.snap @@ -1,5 +1,45 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`decorator-auto-accessors-new-line.ts format 1`] = ` +====================================options===================================== +parsers: ["typescript"] +printWidth: 80 + | printWidth +=====================================input====================================== +class Foo { + accessor + ["bar"]; +} + +class Foo { + static accessor + bar; +} + +class Foo { + accessor + bar; +} + +=====================================output===================================== +class Foo { + accessor; + ["bar"]; +} + +class Foo { + static accessor; + bar; +} + +class Foo { + accessor; + bar; +} + +================================================================================ +`; + exports[`decorator-auto-accessors-type-annotations.ts format 1`] = ` ====================================options===================================== parsers: ["typescript"] diff --git a/tests/format/misc/typescript-only/decorator-auto-accessors-new-line.ts b/tests/format/typescript/decorator-auto-accessors/decorator-auto-accessors-new-line.ts similarity index 100% rename from tests/format/misc/typescript-only/decorator-auto-accessors-new-line.ts rename to tests/format/typescript/decorator-auto-accessors/decorator-auto-accessors-new-line.ts diff --git a/tests/format/typescript/decorator-auto-accessors/no-semi/__snapshots__/jsfmt.spec.js.snap b/tests/format/typescript/decorator-auto-accessors/no-semi/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000000..e9d138cea519 --- /dev/null +++ b/tests/format/typescript/decorator-auto-accessors/no-semi/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,22 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`decorator-auto-accessor-like-property-name.ts - {"semi":false} format 1`] = ` +====================================options===================================== +parsers: ["typescript"] +printWidth: 80 +semi: false + | printWidth +=====================================input====================================== +class C { + accessor; + bar; +} + +=====================================output===================================== +class C { + accessor + bar +} + +================================================================================ +`; diff --git a/tests/format/misc/typescript-only/decorator-auto-accessor-like-property-name.ts b/tests/format/typescript/decorator-auto-accessors/no-semi/decorator-auto-accessor-like-property-name.ts similarity index 100% rename from tests/format/misc/typescript-only/decorator-auto-accessor-like-property-name.ts rename to tests/format/typescript/decorator-auto-accessors/no-semi/decorator-auto-accessor-like-property-name.ts diff --git a/tests/format/typescript/decorator-auto-accessors/no-semi/jsfmt.spec.js b/tests/format/typescript/decorator-auto-accessors/no-semi/jsfmt.spec.js new file mode 100644 index 000000000000..61963c6df408 --- /dev/null +++ b/tests/format/typescript/decorator-auto-accessors/no-semi/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(import.meta, ["typescript"], { semi: false }); diff --git a/tests/format/typescript/decorators/__snapshots__/jsfmt.spec.js.snap b/tests/format/typescript/decorators/__snapshots__/jsfmt.spec.js.snap index 7cb4df4aeaf9..82b11c2eccc4 100644 --- a/tests/format/typescript/decorators/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/typescript/decorators/__snapshots__/jsfmt.spec.js.snap @@ -1,5 +1,72 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`abstract-method.ts [babel-ts] format 1`] = ` +====================================options===================================== +parsers: ["typescript"] +printWidth: 80 + | printWidth +=====================================input====================================== +class A { + @decorator() + abstract method(): Array +} + +=====================================output===================================== +class A { + @decorator() + abstract method(): Array; +} + +================================================================================ +`; + +exports[`abstract-method.ts [typescript] format 1`] = ` +"A decorator can only decorate a method implementation, not an overload. (2:5) + 1 | class A { +> 2 | @decorator() + | ^^^^^^^^^^^^ + 3 | abstract method(): Array + 4 | } + 5 |" +`; + +exports[`accessor.ts [babel-ts] format 1`] = ` +====================================options===================================== +parsers: ["typescript"] +printWidth: 80 + | printWidth +=====================================input====================================== +class A { + @foo() + get a() {return 1} + @bar() + set a(v) {} +} + +=====================================output===================================== +class A { + @foo() + get a() { + return 1; + } + @bar() + set a(v) {} +} + +================================================================================ +`; + +exports[`accessor.ts [typescript] format 1`] = ` +"Decorators cannot be applied to multiple get/set accessors of the same name. (4:5) + 2 | @foo() + 3 | get a() {return 1} +> 4 | @bar() + | ^^^^^^ + 5 | set a(v) {} + 6 | } + 7 |" +`; + exports[`argument-list-preserve-line.ts format 1`] = ` ====================================options===================================== parsers: ["typescript"] @@ -278,12 +345,6 @@ class Something2 { abstract property: Array } -class Something3 { - @foo() - // comment - abstract method(): Array -} - =====================================output===================================== class Foo1 { @foo @@ -321,12 +382,6 @@ class Something2 { abstract property: Array; } -class Something3 { - @foo() - // comment - abstract method(): Array; -} - ================================================================================ `; @@ -467,7 +522,7 @@ import {observable} from "mobx"; } @computed - get total() { + get total2() { return this.price * this.amount; } @@ -476,7 +531,7 @@ import {observable} from "mobx"; this.price = price; } - @computed @computed @computed @computed @computed @computed @computed get total() { + @computed @computed @computed @computed @computed @computed @computed get total3() { return this.price * this.amount; } @@ -506,7 +561,7 @@ class OrderLine { } @computed - get total() { + get total2() { return this.price * this.amount; } @@ -522,7 +577,7 @@ class OrderLine { @computed @computed @computed - get total() { + get total3() { return this.price * this.amount; } diff --git a/tests/format/typescript/decorators/abstract-method.ts b/tests/format/typescript/decorators/abstract-method.ts new file mode 100644 index 000000000000..b93e1ec3fb24 --- /dev/null +++ b/tests/format/typescript/decorators/abstract-method.ts @@ -0,0 +1,4 @@ +class A { + @decorator() + abstract method(): Array +} diff --git a/tests/format/typescript/decorators/accessor.ts b/tests/format/typescript/decorators/accessor.ts new file mode 100644 index 000000000000..578d112f82e9 --- /dev/null +++ b/tests/format/typescript/decorators/accessor.ts @@ -0,0 +1,6 @@ +class A { + @foo() + get a() {return 1} + @bar() + set a(v) {} +} diff --git a/tests/format/typescript/decorators/decorators-comments.ts b/tests/format/typescript/decorators/decorators-comments.ts index 002e8c099744..2f3c378a9444 100644 --- a/tests/format/typescript/decorators/decorators-comments.ts +++ b/tests/format/typescript/decorators/decorators-comments.ts @@ -34,9 +34,3 @@ class Something2 { // comment abstract property: Array } - -class Something3 { - @foo() - // comment - abstract method(): Array -} diff --git a/tests/format/typescript/decorators/jsfmt.spec.js b/tests/format/typescript/decorators/jsfmt.spec.js index 29084a9c8a10..d20e1c41ca3c 100644 --- a/tests/format/typescript/decorators/jsfmt.spec.js +++ b/tests/format/typescript/decorators/jsfmt.spec.js @@ -1 +1,6 @@ -run_spec(import.meta, ["typescript"]); +run_spec(import.meta, ["typescript"], { + errors: { + typescript: ["abstract-method.ts", "accessor.ts"], + "babel-ts": ["issue-9102.ts"], + }, +}); diff --git a/tests/format/typescript/decorators/mobx.ts b/tests/format/typescript/decorators/mobx.ts index bad0c490a7b7..9cab0ed72810 100644 --- a/tests/format/typescript/decorators/mobx.ts +++ b/tests/format/typescript/decorators/mobx.ts @@ -17,7 +17,7 @@ import {observable} from "mobx"; } @computed - get total() { + get total2() { return this.price * this.amount; } @@ -26,7 +26,7 @@ import {observable} from "mobx"; this.price = price; } - @computed @computed @computed @computed @computed @computed @computed get total() { + @computed @computed @computed @computed @computed @computed @computed get total3() { return this.price * this.amount; } diff --git a/tests/format/typescript/type-arguments-bit-shift-left-like/__snapshots__/jsfmt.spec.js.snap b/tests/format/typescript/type-arguments-bit-shift-left-like/__snapshots__/jsfmt.spec.js.snap index 99030dc59eee..8c1278a79a21 100644 --- a/tests/format/typescript/type-arguments-bit-shift-left-like/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/typescript/type-arguments-bit-shift-left-like/__snapshots__/jsfmt.spec.js.snap @@ -67,9 +67,9 @@ printWidth: 80 `; exports[`4.ts [typescript] format 1`] = ` -"Expression expected. (1:2) +"Decorators are not valid here. (1:2) > 1 | (@f<(v: T) => void>() class {}); - | ^ + | ^^^^^^^^^^^^^^^^^^^^^^^ 2 |" `; diff --git a/tests/format/typescript/typeparams/__snapshots__/jsfmt.spec.js.snap b/tests/format/typescript/typeparams/__snapshots__/jsfmt.spec.js.snap index faf9848e007e..f038fd26ae8b 100644 --- a/tests/format/typescript/typeparams/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/typescript/typeparams/__snapshots__/jsfmt.spec.js.snap @@ -286,7 +286,7 @@ const appIDs = createSelector( ================================================================================ `; -exports[`const.ts [babel-ts] format 1`] = ` +exports[`const.ts format 1`] = ` ====================================options===================================== parsers: ["typescript"] printWidth: 80 @@ -362,15 +362,6 @@ class _ { ================================================================================ `; -exports[`const.ts [typescript] format 1`] = ` -"Type parameter declaration expected. (1:12) -> 1 | function a() {} - | ^ - 2 | function b() {} - 3 | function c() {} - 4 | declare function d();" -`; - exports[`long-function-arg.ts format 1`] = ` ====================================options===================================== parsers: ["typescript"] diff --git a/tests/format/typescript/typeparams/jsfmt.spec.js b/tests/format/typescript/typeparams/jsfmt.spec.js index a77412048466..29084a9c8a10 100644 --- a/tests/format/typescript/typeparams/jsfmt.spec.js +++ b/tests/format/typescript/typeparams/jsfmt.spec.js @@ -1 +1 @@ -run_spec(import.meta, ["typescript"], { errors: { typescript: ["const.ts"] } }); +run_spec(import.meta, ["typescript"]); diff --git a/yarn.lock b/yarn.lock index 1257d10dd9b6..d0e0b5e4ac0b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1487,9 +1487,9 @@ __metadata: linkType: hard "@mdn/browser-compat-data@npm:^5.2.34": - version: 5.2.34 - resolution: "@mdn/browser-compat-data@npm:5.2.34" - checksum: 9bb69d42750f38bda526931acc6c9b26f8b032be9ff596d671aa8aadcf6be017635bf42418efa45560c07b770ac01c39d43d4974eb58f25dcaf54b220d88b6a2 + version: 5.2.39 + resolution: "@mdn/browser-compat-data@npm:5.2.39" + checksum: 80bf58e4355c468dce7f859e30064f7fa873971e6e40565b2e0f0cd5593ae29e611b3e341296fe6be1010179f440df4605d45547d846b1768e4e7510560c699b languageName: node linkType: hard @@ -1562,9 +1562,9 @@ __metadata: linkType: hard "@sinclair/typebox@npm:^0.25.16": - version: 0.25.21 - resolution: "@sinclair/typebox@npm:0.25.21" - checksum: 763af1163fe4eabee9b914d4e4548a39fbba3287d2b3b1ff043c1da3c5a321e99d50a3ca94eb182988131e00b006a6f019799cde8da2f61e2f118b30b0276a00 + version: 0.25.24 + resolution: "@sinclair/typebox@npm:0.25.24" + checksum: 10219c58f40b8414c50b483b0550445e9710d4fe7b2c4dccb9b66533dd90ba8e024acc776026cebe81e87f06fa24b07fdd7bc30dd277eb9cc386ec50151a3026 languageName: node linkType: hard @@ -1773,18 +1773,18 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/eslint-plugin@npm:5.54.1": - version: 5.54.1 - resolution: "@typescript-eslint/eslint-plugin@npm:5.54.1" +"@typescript-eslint/eslint-plugin@npm:5.55.0": + version: 5.55.0 + resolution: "@typescript-eslint/eslint-plugin@npm:5.55.0" dependencies: - "@typescript-eslint/scope-manager": 5.54.1 - "@typescript-eslint/type-utils": 5.54.1 - "@typescript-eslint/utils": 5.54.1 + "@eslint-community/regexpp": ^4.4.0 + "@typescript-eslint/scope-manager": 5.55.0 + "@typescript-eslint/type-utils": 5.55.0 + "@typescript-eslint/utils": 5.55.0 debug: ^4.3.4 grapheme-splitter: ^1.0.4 ignore: ^5.2.0 natural-compare-lite: ^1.4.0 - regexpp: ^3.2.0 semver: ^7.3.7 tsutils: ^3.21.0 peerDependencies: @@ -1793,26 +1793,26 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: 76476c08ca0142a9bf6e2381f5cd1c037d86fbafa9c0dded4a97bd3b23b5962dd2c3943bade11b21d674195674f0e36dbf80faa15a1906f5a2ca1f699baf1dd5 + checksum: e3239ec6016eeb73b8b4d8310581978e28b8d3378140a8eb70bd8e33ffd332266020c19d493e0ccae4edfd4abd6097608718c50308fe6288f4ffeb8e4784efd9 languageName: node linkType: hard -"@typescript-eslint/scope-manager@npm:5.54.1": - version: 5.54.1 - resolution: "@typescript-eslint/scope-manager@npm:5.54.1" +"@typescript-eslint/scope-manager@npm:5.55.0": + version: 5.55.0 + resolution: "@typescript-eslint/scope-manager@npm:5.55.0" dependencies: - "@typescript-eslint/types": 5.54.1 - "@typescript-eslint/visitor-keys": 5.54.1 - checksum: 9add24cf3a7852634ad0680a827646860ac4698a6ac8aae31e8b781e29f59e84b51f0cdaacffd0747811012647f01b51969d988da9b302ead374ceebffbe204b + "@typescript-eslint/types": 5.55.0 + "@typescript-eslint/visitor-keys": 5.55.0 + checksum: f253db88f69a29e4abe2f567d0a611cc3e7fb1a911a2cc54a2f6baf16e3de4d1883b3f8e45ee61b3db9fa5543dda0fd7b608de9d28ba6173ab49bfd17ff90cad languageName: node linkType: hard -"@typescript-eslint/type-utils@npm:5.54.1": - version: 5.54.1 - resolution: "@typescript-eslint/type-utils@npm:5.54.1" +"@typescript-eslint/type-utils@npm:5.55.0": + version: 5.55.0 + resolution: "@typescript-eslint/type-utils@npm:5.55.0" dependencies: - "@typescript-eslint/typescript-estree": 5.54.1 - "@typescript-eslint/utils": 5.54.1 + "@typescript-eslint/typescript-estree": 5.55.0 + "@typescript-eslint/utils": 5.55.0 debug: ^4.3.4 tsutils: ^3.21.0 peerDependencies: @@ -1820,23 +1820,23 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: 0073838b782b7f4619775be124ca6643fec43a2d56043eaf3ceb100960a5193f14ac747b28ce17a5c9ac643fdee8abda82a7d905c81521358de7b27a2dcbc9af + checksum: 5c60d441355b51f96b596324068c10605c74abb46748c0bbc6d8f7f2ea40acb6b4bda3b537105fa189172324c56d18bd88e7102e67f99f8c03bc05c6d0e2023d languageName: node linkType: hard -"@typescript-eslint/types@npm:5.54.1": - version: 5.54.1 - resolution: "@typescript-eslint/types@npm:5.54.1" - checksum: 84a8f725cfa10646af389659e09c510c38d82c65960c7b613f844a264acc0e197471cba03f3e8f4b6411bc35dca28922c8352a7bd44621411c73fd6dd4096da2 +"@typescript-eslint/types@npm:5.55.0": + version: 5.55.0 + resolution: "@typescript-eslint/types@npm:5.55.0" + checksum: 7d851f09a2106514d3a9c7164d34758f30abfe554e3c7a02be75cdc7e16644e23ca32840a8f39a0321bc509927fb4d98ce91b22b21e8544ac56cef33b815a864 languageName: node linkType: hard -"@typescript-eslint/typescript-estree@npm:5.54.1": - version: 5.54.1 - resolution: "@typescript-eslint/typescript-estree@npm:5.54.1" +"@typescript-eslint/typescript-estree@npm:5.55.0": + version: 5.55.0 + resolution: "@typescript-eslint/typescript-estree@npm:5.55.0" dependencies: - "@typescript-eslint/types": 5.54.1 - "@typescript-eslint/visitor-keys": 5.54.1 + "@typescript-eslint/types": 5.55.0 + "@typescript-eslint/visitor-keys": 5.55.0 debug: ^4.3.4 globby: ^11.1.0 is-glob: ^4.0.3 @@ -1845,35 +1845,35 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: ea42bdb4832fa96fa1121237c9b664ac4506e2836646651e08a8542c8601d78af6c288779707f893ca4c884221829bb7d7b4b43c4a9c3ed959519266d03a139b + checksum: d24a11aee3d01067018d99804f420aecb8af88e43bf170d5d14f6480bd378c0a81ce49a37f5d6c36e5f0f319e3fa8b099720f295f2767338be1a4f7e9a5323e1 languageName: node linkType: hard -"@typescript-eslint/utils@npm:5.54.1, @typescript-eslint/utils@npm:^5.10.0": - version: 5.54.1 - resolution: "@typescript-eslint/utils@npm:5.54.1" +"@typescript-eslint/utils@npm:5.55.0, @typescript-eslint/utils@npm:^5.10.0": + version: 5.55.0 + resolution: "@typescript-eslint/utils@npm:5.55.0" dependencies: + "@eslint-community/eslint-utils": ^4.2.0 "@types/json-schema": ^7.0.9 "@types/semver": ^7.3.12 - "@typescript-eslint/scope-manager": 5.54.1 - "@typescript-eslint/types": 5.54.1 - "@typescript-eslint/typescript-estree": 5.54.1 + "@typescript-eslint/scope-manager": 5.55.0 + "@typescript-eslint/types": 5.55.0 + "@typescript-eslint/typescript-estree": 5.55.0 eslint-scope: ^5.1.1 - eslint-utils: ^3.0.0 semver: ^7.3.7 peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 - checksum: 8f428ea4d338ce85d55fd0c9ae2b217b323f29f51b7c9f8077fef7001ca21d28b032c5e5165b67ae6057aef69edb0e7a164c3c483703be6f3e4e574248bbc399 + checksum: 368cfc3fb9d6af6901e739e2e41c3f7f1c1244576607445f4f59d95eccb237f73e1a75e7f0816ec9a32a0f1ec6bb4a3602a99e17e70fe184e62f7c69dcbe4b8d languageName: node linkType: hard -"@typescript-eslint/visitor-keys@npm:5.54.1": - version: 5.54.1 - resolution: "@typescript-eslint/visitor-keys@npm:5.54.1" +"@typescript-eslint/visitor-keys@npm:5.55.0": + version: 5.55.0 + resolution: "@typescript-eslint/visitor-keys@npm:5.55.0" dependencies: - "@typescript-eslint/types": 5.54.1 + "@typescript-eslint/types": 5.55.0 eslint-visitor-keys: ^3.3.0 - checksum: 3a691abd2a43b86a0c41526d14a2afcc93a2e0512b5f8b9ec43f6029c493870808036eae5ee4fc655d26e1999017c4a4dffb241f47c36c2a1238ec9fbd08719c + checksum: 0b24c72dff99dd2cf41c19d20067f8ab20a38aa2e82c79c5530bec7cf651031e95c80702fc21c813c9b94e5f3d4cd210f13967b2966ef38abe548cb5f05848a3 languageName: node linkType: hard @@ -2443,9 +2443,9 @@ __metadata: linkType: hard "caniuse-lite@npm:^1.0.30001449, caniuse-lite@npm:^1.0.30001451": - version: 1.0.30001456 - resolution: "caniuse-lite@npm:1.0.30001456" - checksum: c2cc479962149abd09a25b64699ee7484d9c433db2bad0a489f7b51b09a463c991f6efd7b8e201bc1a1ccf3294263f88503a3adf0a57db9046939ee7e58b76a6 + version: 1.0.30001458 + resolution: "caniuse-lite@npm:1.0.30001458" + checksum: 258cc5a25babbbfe483bf788c6f321a19400ff80b2bf156b360bac09a6f9f4da44516350d187a30395667cb142c682d9ea96577ea0df236d35f76234b07ccb41 languageName: node linkType: hard @@ -3140,9 +3140,9 @@ __metadata: linkType: hard "electron-to-chromium@npm:^1.4.284": - version: 1.4.286 - resolution: "electron-to-chromium@npm:1.4.286" - checksum: 6b53e2aea63892cb4af85ea4ee5ed2b6d848713519987efcf4c1177a32e2fe6d04a7f591f5bcd1feab0b3c88890c6eaf65b6feb16c0e0319bf07e31de31930af + version: 1.4.315 + resolution: "electron-to-chromium@npm:1.4.315" + checksum: 9b1e9a43afe086aaed9af2a60076a409c0d6a0d9a9f4d0a293131763329c48c86198bda4020155c7ce53d2569840d49d51e8ce2405b6cd90000a77c1bd650ea5 languageName: node linkType: hard @@ -3739,11 +3739,11 @@ __metadata: linkType: hard "esquery@npm:^1.4.0, esquery@npm:^1.4.2": - version: 1.4.2 - resolution: "esquery@npm:1.4.2" + version: 1.5.0 + resolution: "esquery@npm:1.5.0" dependencies: estraverse: ^5.1.0 - checksum: 2f4ad89c5aafaca61cc2c15e256190f0d6deb4791cae6552d3cb4b1eb8867958cdf27a56aaa3272ff17435e3eaa19ee0d4129fac336ca6373d7354d7b5da7966 + checksum: aefb0d2596c230118656cd4ec7532d447333a410a48834d80ea648b1e7b5c9bc9ed8b5e33a89cb04e487b60d622f44cf5713bf4abed7c97343edefdc84a35900 languageName: node linkType: hard @@ -4115,7 +4115,7 @@ __metadata: languageName: node linkType: hard -"get-intrinsic@npm:^1.0.2, get-intrinsic@npm:^1.1.1, get-intrinsic@npm:^1.1.3": +"get-intrinsic@npm:^1.0.2, get-intrinsic@npm:^1.1.0, get-intrinsic@npm:^1.1.1, get-intrinsic@npm:^1.1.3": version: 1.1.3 resolution: "get-intrinsic@npm:1.1.3" dependencies: @@ -4583,13 +4583,13 @@ __metadata: linkType: hard "internal-slot@npm:^1.0.3": - version: 1.0.4 - resolution: "internal-slot@npm:1.0.4" + version: 1.0.3 + resolution: "internal-slot@npm:1.0.3" dependencies: - get-intrinsic: ^1.1.3 + get-intrinsic: ^1.1.0 has: ^1.0.3 side-channel: ^1.0.4 - checksum: 8974588d06bab4f675573a3b52975370facf6486df51bc0567a982c7024fa29495f10b76c0d4dc742dd951d1b72024fdc1e31bb0bedf1678dc7aacacaf5a4f73 + checksum: 1944f92e981e47aebc98a88ff0db579fd90543d937806104d0b96557b10c1f170c51fb777b97740a8b6ddeec585fca8c39ae99fd08a8e058dfc8ab70937238bf languageName: node linkType: hard @@ -6120,9 +6120,9 @@ __metadata: linkType: hard "node-releases@npm:^2.0.8": - version: 2.0.9 - resolution: "node-releases@npm:2.0.9" - checksum: 3ae6b1b300dc72c1a628861093d339a01aa017d3ad9017b0478384be29d6f9c93b9e26c91fce79728cecaadc04d0f16834b7ae1a018730e3e54962ec8c6aa86f + version: 2.0.10 + resolution: "node-releases@npm:2.0.10" + checksum: d784ecde25696a15d449c4433077f5cce620ed30a1656c4abf31282bfc691a70d9618bae6868d247a67914d1be5cc4fde22f65a05f4398cdfb92e0fc83cadfbc languageName: node linkType: hard @@ -6745,9 +6745,9 @@ __metadata: "@types/file-entry-cache": 5.0.2 "@types/find-cache-dir": 3.2.1 "@types/jest": 29.4.0 - "@typescript-eslint/eslint-plugin": 5.54.1 - "@typescript-eslint/typescript-estree": 5.54.1 - "@typescript-eslint/visitor-keys": 5.54.1 + "@typescript-eslint/eslint-plugin": 5.55.0 + "@typescript-eslint/typescript-estree": 5.55.0 + "@typescript-eslint/visitor-keys": 5.55.0 acorn: 8.8.2 acorn-jsx: 5.3.2 angular-estree-parser: 6.0.0 @@ -6842,7 +6842,7 @@ __metadata: tempy: 3.0.0 to-fast-properties: 4.0.0 ts-expect: 1.3.0 - typescript: 4.9.5 + typescript: 5.0.1-rc unicode-regex: 3.0.0 unified: 9.2.2 vnopts: 1.0.2 @@ -8133,23 +8133,23 @@ __metadata: languageName: node linkType: hard -"typescript@npm:4.9.5": - version: 4.9.5 - resolution: "typescript@npm:4.9.5" +"typescript@npm:5.0.1-rc": + version: 5.0.1-rc + resolution: "typescript@npm:5.0.1-rc" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: ee000bc26848147ad423b581bd250075662a354d84f0e06eb76d3b892328d8d4440b7487b5a83e851b12b255f55d71835b008a66cbf8f255a11e4400159237db + checksum: 47e2381464f0b8a2d54ddb60ddd44a57577462d5faecd7db445b8b24a02d6f16d117fd4f49ba66fe8e22c49b79f5bfb1b6851e1e32e29c6d4c2ab324bc184b70 languageName: node linkType: hard -"typescript@patch:typescript@4.9.5#~builtin": - version: 4.9.5 - resolution: "typescript@patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=23ec76" +"typescript@patch:typescript@5.0.1-rc#~builtin": + version: 5.0.1-rc + resolution: "typescript@patch:typescript@npm%3A5.0.1-rc#~builtin::version=5.0.1-rc&hash=1f5320" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: ab417a2f398380c90a6cf5a5f74badd17866adf57f1165617d6a551f059c3ba0a3e4da0d147b3ac5681db9ac76a303c5876394b13b3de75fdd5b1eaa06181c9d + checksum: 61b43eb0e562e61f311c3138854d75a7d9f57153df6b7a4a509db76ae8aea2029116186fb391fa266c00b1e36c16daa075baf5e23f0bb133f9281adf6ca308f7 languageName: node linkType: hard