diff --git a/changelog_unreleased/typescript/14391.md b/changelog_unreleased/typescript/14391.md new file mode 100644 index 000000000000..d99d1faf00e0 --- /dev/null +++ b/changelog_unreleased/typescript/14391.md @@ -0,0 +1,6 @@ +#### Support TypeScript 5.0 (#14391 by @fisker, #13819 by @fisker, @sosukesuzuki) + +TypeScript 5.0 introduces two new syntactic features: + +- `const` modifiers for type parameters +- `export type *` declarations diff --git a/cspell.json b/cspell.json index bd8c7e7d4a94..2a89cde4cf50 100644 --- a/cspell.json +++ b/cspell.json @@ -339,6 +339,7 @@ "Tradeshift", "Transloadit", "trippable", + "tsbuild", "tsep", "TSES", "TSJS", diff --git a/package.json b/package.json index f117713ee841..ed9fb3daf18d 100644 --- a/package.json +++ b/package.json @@ -24,10 +24,10 @@ "dependencies": { "@angular/compiler": "12.2.16", "@babel/code-frame": "7.18.6", - "@babel/parser": "7.20.7", + "@babel/parser": "7.21.3", "@glimmer/syntax": "0.84.2", "@iarna/toml": "2.2.5", - "@typescript-eslint/typescript-estree": "5.45.0", + "@typescript-eslint/typescript-estree": "5.55.0", "acorn": "8.8.1", "acorn-jsx": "5.3.2", "angular-estree-parser": "2.5.1", @@ -85,7 +85,7 @@ "semver": "7.3.7", "string-width": "5.0.1", "strip-ansi": "7.0.1", - "typescript": "4.9.3", + "typescript": "5.0.2", "unicode-regex": "3.0.0", "unified": "9.2.1", "vnopts": "1.0.2", @@ -93,7 +93,7 @@ "yaml-unist-parser": "1.3.1" }, "devDependencies": { - "@babel/core": "7.20.7", + "@babel/core": "7.21.3", "@babel/preset-env": "7.20.2", "@babel/types": "7.20.7", "@esbuild-plugins/node-modules-polyfill": "0.1.4", @@ -102,7 +102,7 @@ "@types/file-entry-cache": "5.0.2", "@types/find-cache-dir": "3.2.1", "@types/jest": "27.4.1", - "@typescript-eslint/eslint-plugin": "5.36.2", + "@typescript-eslint/eslint-plugin": "5.55.0", "babel-jest": "27.5.1", "benchmark": "2.1.4", "browserslist-to-esbuild": "1.2.0", diff --git a/scripts/build/modify-typescript-module.mjs b/scripts/build/modify-typescript-module.mjs index 634abd5fbf1e..5ab60a80f0b3 100644 --- a/scripts/build/modify-typescript-module.mjs +++ b/scripts/build/modify-typescript-module.mjs @@ -4,92 +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) { - return this; - - // TODO: Enable this check when merge to `next` branch - // 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 = "" }) { @@ -116,374 +106,188 @@ class TypeScriptModuleSource { return this; } + prepend(...args) { + this.#source.prepend(...args); + return this; + } + append(...args) { this.#source.append(...args); return this; } + replace(...args) { + this.#source.replace(...args); + return this; + } + replaceAll(...args) { this.#source.replaceAll(...args); return this; } + applyChanges() { + const text = this.#source.toString(); + this.#source = new MagicString(text); + this.modules = getModules(text); + } + toString() { return this.#source.toString(); } } -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;") - ); - - // `ts.Version` - source.removeSubmodule((text) => text.includes("ts.Version = Version;")); - - // `ts.transform` - source.removeSubmodule((text) => text.includes("ts.transform = transform;")); - - // `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;" - ) - ); + return text.slice(start + startMark.length, end); +} - // 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;") - ); +function modifyTypescriptModule(text) { + text = unwrap(text); - // `ts.transformNodes` and more - source.removeSubmodule((text) => - text.includes("ts.transformNodes = transformNodes;") - ); + const source = new TypeScriptModuleSource(text); - // `ts.server` - source.removeSubmodule((text) => text.includes("(ts.server = {})")); + // Deprecated + for (const module of source.modules) { + if (module.path.startsWith("src/deprecatedCompat/")) { + source.removeModule(module); + } + } - // `ts.JsTyping` - source.removeSubmodule((text) => text.includes("(ts.JsTyping = {})")); + // jsTyping + for (const module of source.modules) { + if (module.path.startsWith("src/jsTyping/")) { + source.removeModule(module); + } + } - // `ts.ClassificationType` - source.removeSubmodule((text) => - text.includes("(ts.ClassificationType = {})") - ); + // services + for (const module of source.modules) { + if ( + module.path === "src/services/services.ts" || + module.path === "src/services/_namespaces/ts.ts" + ) { + continue; + } - // 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;") - ); + // 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; + } - // 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;") - ); + 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 = {})")); + source.removeModule("src/compiler/_namespaces/ts.moduleSpecifiers.ts"); + source.removeModule("src/compiler/moduleSpecifiers.ts"); - // `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;") - ); - - // `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: () => () => {}}); ` ); - for (const [find, replacement] of Object.entries({ - // yarn pnp - "process.versions.pnp": "undefined", + /* spell-checker: disable */ + // `ts.createParenthesizerRules` + source.replaceAlignedCode({ + start: "function createParenthesizerRules(", + end: "}", + }); + /* spell-checker: enable */ - // Dynamic `require()`s - "ts.sys && ts.sys.require": "false", - "require(etwModulePath)": "undefined", - })) { - source.replaceAll(find, replacement); - } + source.replaceAlignedCode({ + start: "function getScriptTargetFeatures(", + end: "}", + }); source.replaceAlignedCode({ - start: "var debugObjectHost = (function () {", - end: "})();", + start: "var __require = ", + end: "});", }); + source.append("module.exports = require_typescript();"); + return source.toString(); } diff --git a/scripts/release/release.js b/scripts/release/release.js index d6a03e17edff..002a1eb35289 100644 --- a/scripts/release/release.js +++ b/scripts/release/release.js @@ -42,7 +42,7 @@ async function run() { const steps = await Promise.all( [ - "./steps/validate-new-version.js", + // "./steps/validate-new-version.js", "./steps/check-git-status.js", !params["skip-dependencies-install"] && "./steps/install-dependencies.js", params.manual && "./steps/run-tests.js", diff --git a/src/language-js/parse/postprocess/index.js b/src/language-js/parse/postprocess/index.js index d2005c4f1f34..d132f7c86bcb 100644 --- a/src/language-js/parse/postprocess/index.js +++ b/src/language-js/parse/postprocess/index.js @@ -5,18 +5,9 @@ const isTsKeywordType = require("../../utils/is-ts-keyword-type.js"); const isTypeCastComment = require("../../utils/is-type-cast-comment.js"); const getLast = require("../../../utils/get-last.js"); const visitNode = require("./visit-node.js"); -const { throwErrorForInvalidNodes } = require("./typescript.js"); const throwSyntaxError = require("./throw-syntax-error.js"); function postprocess(ast, options) { - if ( - options.parser === "typescript" && - // decorators or abstract properties - /@|abstract/.test(options.originalText) - ) { - throwErrorForInvalidNodes(ast, options); - } - // Keep Babel's non-standard ParenthesizedExpression nodes only if they have Closure-style type cast comments. if ( options.parser !== "typescript" && diff --git a/src/language-js/parse/postprocess/typescript.js b/src/language-js/parse/postprocess/typescript.js index 314999472623..9b343a766a74 100644 --- a/src/language-js/parse/postprocess/typescript.js +++ b/src/language-js/parse/postprocess/typescript.js @@ -19,25 +19,76 @@ function getSourceFileOfNode(node) { return node; } +function throwErrorOnTsNode(node, message) { + const sourceFile = getSourceFileOfNode(node); + const [start, end] = [node.getStart(), node.end].map((position) => { + const { line, character: column } = + sourceFile.getLineAndCharacterOfPosition(position); + return { line: line + 1, column }; + }); + + throwSyntaxError({ loc: { start, end } }, 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)) { +function throwErrorForInvalidDecorator(node) { + const { modifiers } = node; + if (!isNonEmptyArray(modifiers)) { return; } - const [{ expression }] = illegalDecorators; + const ts = require("typescript"); - const sourceFile = getSourceFileOfNode(expression); - const [start, end] = [expression.pos, expression.end].map((position) => { - const { line, character: column } = - sourceFile.getLineAndCharacterOfPosition(position); - return { line: line + 1, column }; - }); - - throwSyntaxError({ loc: { start, end } }, "Decorators are not valid here."); + const { SyntaxKind } = ts; + for (const modifier of modifiers) { + if (ts.isDecorator(modifier)) { + 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." + ); + } + } + } + } } // Values of abstract property is removed since `@typescript-eslint/typescript-estree` v5 @@ -60,11 +111,17 @@ function throwErrorForInvalidAbstractProperty(tsNode, esTreeNode) { } } -function throwErrorForInvalidNodes(ast, options) { - const { esTreeNodeToTSNodeMap, tsNodeToESTreeNodeMap } = - options.tsParseResult; +function throwErrorForInvalidNodes(result, options) { + if ( + // decorators or abstract properties + !/@|abstract/.test(options.originalText) + ) { + return; + } + + const { esTreeNodeToTSNodeMap, tsNodeToESTreeNodeMap } = result; - visitNode(ast, (node) => { + visitNode(result.ast, (node) => { const tsNode = esTreeNodeToTSNodeMap.get(node); if (!tsNode) { return; diff --git a/src/language-js/parse/typescript.js b/src/language-js/parse/typescript.js index a359fe8480f9..8a733ae7ec07 100644 --- a/src/language-js/parse/typescript.js +++ b/src/language-js/parse/typescript.js @@ -5,6 +5,7 @@ const tryCombinations = require("../../utils/try-combinations.js"); const createParser = require("./utils/create-parser.js"); const replaceHashbang = require("./utils/replace-hashbang.js"); const postprocess = require("./postprocess/index.js"); +const { throwErrorForInvalidNodes } = require("./postprocess/typescript.js"); /** @type {import("@typescript-eslint/typescript-estree").TSESTreeOptions} */ const parseOptions = { @@ -50,7 +51,8 @@ function parse(text, parsers, options = {}) { } options.originalText = text; - options.tsParseResult = result; + throwErrorForInvalidNodes(result, options); + return postprocess(result.ast, options); } diff --git a/src/language-js/print/type-parameters.js b/src/language-js/print/type-parameters.js index 7154b97de4b4..792d3584cbd0 100644 --- a/src/language-js/print/type-parameters.js +++ b/src/language-js/print/type-parameters.js @@ -107,7 +107,7 @@ function printDanglingCommentsForInline(path, options) { function printTypeParameter(path, options, print) { const node = path.getValue(); - const parts = []; + const parts = [node.type === "TSTypeParameter" && node.const ? "const " : ""]; const parent = path.getParentNode(); if (parent.type === "TSMappedType") { if (parent.readonly) { 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 e12bdedd8818..123d72efa2a2 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 |" `; @@ -145,9 +145,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 {});" @@ -181,9 +181,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 {});" @@ -337,9 +337,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 |" `; @@ -369,9 +369,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 |" `; @@ -449,9 +449,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 |" @@ -485,9 +485,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/export-extension/__snapshots__/jsfmt.spec.js.snap b/tests/format/js/export-default/export-default-from/__snapshots__/jsfmt.spec.js.snap similarity index 82% rename from tests/format/js/export-extension/__snapshots__/jsfmt.spec.js.snap rename to tests/format/js/export-default/export-default-from/__snapshots__/jsfmt.spec.js.snap index 5de3516e70c2..fa0a79dc12d2 100644 --- a/tests/format/js/export-extension/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/js/export-default/export-default-from/__snapshots__/jsfmt.spec.js.snap @@ -7,7 +7,7 @@ exports[`export.js [acorn] format 1`] = ` | ^ 3 | export a, * as b from 'mod'; 4 | export c, { foo } from 'mod'; - 5 | export * as d, { bar } from 'mod';" + 5 | export * as d from 'mod';" `; exports[`export.js [espree] format 1`] = ` @@ -17,7 +17,7 @@ exports[`export.js [espree] format 1`] = ` | ^ 3 | export a, * as b from 'mod'; 4 | export c, { foo } from 'mod'; - 5 | export * as d, { bar } from 'mod';" + 5 | export * as d from 'mod';" `; exports[`export.js [meriyah] format 1`] = ` @@ -27,7 +27,7 @@ exports[`export.js [meriyah] format 1`] = ` | ^ 3 | export a, * as b from 'mod'; 4 | export c, { foo } from 'mod'; - 5 | export * as d, { bar } from 'mod';" + 5 | export * as d from 'mod';" `; exports[`export.js format 1`] = ` @@ -40,9 +40,9 @@ export * as ns from 'mod'; export v from 'mod'; export a, * as b from 'mod'; export c, { foo } from 'mod'; -export * as d, { bar } from 'mod'; +export * as d from 'mod'; export { fooooooooooooooooooooooooooooooooooooooooooooooooo } from "fooooooooooooooooooooooooooooo"; -export Bar, { barrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr } from "barrrrrrrrrrrrrrrrrrrrrrrrrrrr"; +export Bar from "barrrrrrrrrrrrrrrrrrrrrrrrrrrr"; export { foooooooooooooooooooooooooooooooooooooooooooooo, fooooooooooooooooooooooooooooooooooooooooooooooo } from "fooooooooooooooooooooooooooooo"; =====================================output===================================== @@ -50,11 +50,9 @@ export * as ns from "mod"; export v from "mod"; export a, * as b from "mod"; export c, { foo } from "mod"; -export * as d, { bar } from "mod"; +export * as d from "mod"; export { fooooooooooooooooooooooooooooooooooooooooooooooooo } from "fooooooooooooooooooooooooooooo"; -export Bar, { - barrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr, -} from "barrrrrrrrrrrrrrrrrrrrrrrrrrrr"; +export Bar from "barrrrrrrrrrrrrrrrrrrrrrrrrrrr"; export { foooooooooooooooooooooooooooooooooooooooooooooo, fooooooooooooooooooooooooooooooooooooooooooooooo, diff --git a/tests/format/js/export-extension/export.js b/tests/format/js/export-default/export-default-from/export.js similarity index 72% rename from tests/format/js/export-extension/export.js rename to tests/format/js/export-default/export-default-from/export.js index 2626fe4adb41..cdc56d1279ca 100644 --- a/tests/format/js/export-extension/export.js +++ b/tests/format/js/export-default/export-default-from/export.js @@ -2,7 +2,7 @@ export * as ns from 'mod'; export v from 'mod'; export a, * as b from 'mod'; export c, { foo } from 'mod'; -export * as d, { bar } from 'mod'; +export * as d from 'mod'; export { fooooooooooooooooooooooooooooooooooooooooooooooooo } from "fooooooooooooooooooooooooooooo"; -export Bar, { barrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr } from "barrrrrrrrrrrrrrrrrrrrrrrrrrrr"; +export Bar from "barrrrrrrrrrrrrrrrrrrrrrrrrrrr"; export { foooooooooooooooooooooooooooooooooooooooooooooo, fooooooooooooooooooooooooooooooooooooooooooooooo } from "fooooooooooooooooooooooooooooo"; diff --git a/tests/format/js/export-extension/jsfmt.spec.js b/tests/format/js/export-default/export-default-from/jsfmt.spec.js similarity index 100% rename from tests/format/js/export-extension/jsfmt.spec.js rename to tests/format/js/export-default/export-default-from/jsfmt.spec.js diff --git a/tests/format/js/export-star/__snapshots__/jsfmt.spec.js.snap b/tests/format/js/export-star/__snapshots__/jsfmt.spec.js.snap index c0b2eac462f2..e0d758b5e384 100644 --- a/tests/format/js/export-star/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/js/export-star/__snapshots__/jsfmt.spec.js.snap @@ -51,6 +51,35 @@ export * as default from "foo"; ================================================================================ `; +exports[`export-star-as-reserved-word.js [flow] format 1`] = ` +"Unexpected token \`function\` (1:13) +> 1 | export * as function from 'foo' + | ^^^^^^^^ + 2 | export * as const from 'foo' + 3 | export * as as from 'foo' + 4 | export * as from from 'foo'" +`; + +exports[`export-star-as-reserved-word.js format 1`] = ` +====================================options===================================== +parsers: ["babel", "flow", "typescript"] +printWidth: 80 + | printWidth +=====================================input====================================== +export * as function from 'foo' +export * as const from 'foo' +export * as as from 'foo' +export * as from from 'foo' + +=====================================output===================================== +export * as function from "foo"; +export * as const from "foo"; +export * as as from "foo"; +export * as from from "foo"; + +================================================================================ +`; + exports[`export-star-as-string.js [flow] format 1`] = ` "Unexpected string, expected an identifier (1:13) > 1 | export * as 'foo' from 'foo' diff --git a/tests/format/js/export-star/export-star-as-reserved-word.js b/tests/format/js/export-star/export-star-as-reserved-word.js new file mode 100644 index 000000000000..0bfa9bc8a2dd --- /dev/null +++ b/tests/format/js/export-star/export-star-as-reserved-word.js @@ -0,0 +1,4 @@ +export * as function from 'foo' +export * as const from 'foo' +export * as as from 'foo' +export * as from from 'foo' diff --git a/tests/format/js/export-star/jsfmt.spec.js b/tests/format/js/export-star/jsfmt.spec.js index 64f60bb69348..a96c304ecf10 100644 --- a/tests/format/js/export-star/jsfmt.spec.js +++ b/tests/format/js/export-star/jsfmt.spec.js @@ -4,6 +4,7 @@ run_spec(__dirname, ["babel", "flow", "typescript"], { "export-star-as-default.js", "export-star-as-string.js", "export-star-as-string2.js", + "export-star-as-reserved-word.js", ], typescript: ["export-star-as-string.js", "export-star-as-string2.js"], }, diff --git a/tests/format/js/export/__snapshots__/jsfmt.spec.js.snap b/tests/format/js/export/__snapshots__/jsfmt.spec.js.snap index ae949438c816..89f34379b17a 100644 --- a/tests/format/js/export/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/js/export/__snapshots__/jsfmt.spec.js.snap @@ -287,3 +287,103 @@ export { c as /* comment */ c } from "c"; ================================================================================ `; + +exports[`test.js - {"bracketSpacing":false} format 1`] = ` +====================================options===================================== +bracketSpacing: false +parsers: ["babel", "flow", "typescript"] +printWidth: 80 + | printWidth +=====================================input====================================== +export { value1, value2 as value2_renamed, value3, value4 as value4_renamed, value5 } from "exports"; + +export * as ns from "mod"; + +export * as foo from "./baz"; + +=====================================output===================================== +export { + value1, + value2 as value2_renamed, + value3, + value4 as value4_renamed, + value5, +} from "exports"; + +export * as ns from "mod"; + +export * as foo from "./baz"; + +================================================================================ +`; + +exports[`test.js format 1`] = ` +====================================options===================================== +parsers: ["babel", "flow", "typescript"] +printWidth: 80 + | printWidth +=====================================input====================================== +export { value1, value2 as value2_renamed, value3, value4 as value4_renamed, value5 } from "exports"; + +export * as ns from "mod"; + +export * as foo from "./baz"; + +=====================================output===================================== +export { + value1, + value2 as value2_renamed, + value3, + value4 as value4_renamed, + value5, +} from "exports"; + +export * as ns from "mod"; + +export * as foo from "./baz"; + +================================================================================ +`; + +exports[`undefined.js [espree] format 1`] = ` +"Export 'undefinedExport' is not defined (1:10) +> 1 | export { undefinedExport }; + | ^ + 2 |" +`; + +exports[`undefined.js - {"bracketSpacing":false} [espree] format 1`] = ` +"Export 'undefinedExport' is not defined (1:10) +> 1 | export { undefinedExport }; + | ^ + 2 |" +`; + +exports[`undefined.js - {"bracketSpacing":false} format 1`] = ` +====================================options===================================== +bracketSpacing: false +parsers: ["babel", "flow", "typescript"] +printWidth: 80 + | printWidth +=====================================input====================================== +export { undefinedExport }; + +=====================================output===================================== +export {undefinedExport}; + +================================================================================ +`; + +exports[`undefined.js format 1`] = ` +====================================options===================================== +parsers: ["babel", "flow", "typescript"] +printWidth: 80 + | printWidth +=====================================input====================================== +export { undefinedExport }; + +=====================================output===================================== +export { undefinedExport }; + +================================================================================ +`; diff --git a/tests/format/js/export/jsfmt.spec.js b/tests/format/js/export/jsfmt.spec.js index df3db0cc4bb6..70e567c0cbfc 100644 --- a/tests/format/js/export/jsfmt.spec.js +++ b/tests/format/js/export/jsfmt.spec.js @@ -1,2 +1,7 @@ -run_spec(__dirname, ["babel", "flow", "typescript"]); -run_spec(__dirname, ["babel", "flow", "typescript"], { bracketSpacing: false }); +run_spec(__dirname, ["babel", "flow", "typescript"], { + errors: { espree: ["undefined.js"] }, +}); +run_spec(__dirname, ["babel", "flow", "typescript"], { + bracketSpacing: false, + errors: { espree: ["undefined.js"] }, +}); diff --git a/tests/format/js/exports/test.js b/tests/format/js/export/test.js similarity index 58% rename from tests/format/js/exports/test.js rename to tests/format/js/export/test.js index af917844eaf7..749b5c499844 100644 --- a/tests/format/js/exports/test.js +++ b/tests/format/js/export/test.js @@ -1,9 +1,5 @@ export { value1, value2 as value2_renamed, value3, value4 as value4_renamed, value5 } from "exports"; -export a,{b} from "./baz"; - export * as ns from "mod"; -export * as foo,{bar} from "./baz"; - -export { undefinedExport }; +export * as foo from "./baz"; diff --git a/tests/format/js/export/undefined.js b/tests/format/js/export/undefined.js new file mode 100644 index 000000000000..7d3cb1fcccfe --- /dev/null +++ b/tests/format/js/export/undefined.js @@ -0,0 +1 @@ +export { undefinedExport }; diff --git a/tests/format/js/exports/__snapshots__/jsfmt.spec.js.snap b/tests/format/js/exports/__snapshots__/jsfmt.spec.js.snap deleted file mode 100644 index 711cd20bacb7..000000000000 --- a/tests/format/js/exports/__snapshots__/jsfmt.spec.js.snap +++ /dev/null @@ -1,70 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`test.js [acorn] format 1`] = ` -"Unexpected token (3:8) - 1 | export { value1, value2 as value2_renamed, value3, value4 as value4_renamed, value5 } from "exports"; - 2 | -> 3 | export a,{b} from "./baz"; - | ^ - 4 | - 5 | export * as ns from "mod"; - 6 |" -`; - -exports[`test.js [espree] format 1`] = ` -"Unexpected token a (3:8) - 1 | export { value1, value2 as value2_renamed, value3, value4 as value4_renamed, value5 } from "exports"; - 2 | -> 3 | export a,{b} from "./baz"; - | ^ - 4 | - 5 | export * as ns from "mod"; - 6 |" -`; - -exports[`test.js [meriyah] format 1`] = ` -"Unexpected token: 'identifier' (3:8) - 1 | export { value1, value2 as value2_renamed, value3, value4 as value4_renamed, value5 } from "exports"; - 2 | -> 3 | export a,{b} from "./baz"; - | ^ - 4 | - 5 | export * as ns from "mod"; - 6 |" -`; - -exports[`test.js format 1`] = ` -====================================options===================================== -parsers: ["babel"] -printWidth: 80 - | printWidth -=====================================input====================================== -export { value1, value2 as value2_renamed, value3, value4 as value4_renamed, value5 } from "exports"; - -export a,{b} from "./baz"; - -export * as ns from "mod"; - -export * as foo,{bar} from "./baz"; - -export { undefinedExport }; - -=====================================output===================================== -export { - value1, - value2 as value2_renamed, - value3, - value4 as value4_renamed, - value5, -} from "exports"; - -export a, { b } from "./baz"; - -export * as ns from "mod"; - -export * as foo, { bar } from "./baz"; - -export { undefinedExport }; - -================================================================================ -`; diff --git a/tests/format/js/exports/jsfmt.spec.js b/tests/format/js/exports/jsfmt.spec.js deleted file mode 100644 index 8ec1e5a27f4b..000000000000 --- a/tests/format/js/exports/jsfmt.spec.js +++ /dev/null @@ -1,3 +0,0 @@ -run_spec(__dirname, ["babel"], { - errors: { acorn: true, espree: true, meriyah: true }, -}); 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/errors/js/optional-chaining/__snapshots__/jsfmt.spec.js.snap b/tests/format/misc/errors/js/optional-chaining/__snapshots__/jsfmt.spec.js.snap index 3c7930cfbe9a..ed0341343adb 100644 --- a/tests/format/misc/errors/js/optional-chaining/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/misc/errors/js/optional-chaining/__snapshots__/jsfmt.spec.js.snap @@ -7,9 +7,9 @@ exports[`snippet: #0 [acorn] format 1`] = ` `; exports[`snippet: #0 [babel] format 1`] = ` -"Constructors in/after an Optional Chain are not allowed. (1:36) +"Constructors in/after an Optional Chain are not allowed. (1:21) > 1 | const baz3 = new obj?.foo?.bar?.baz(); // baz instance - | ^" + | ^" `; exports[`snippet: #0 [espree] format 1`] = ` @@ -31,9 +31,9 @@ exports[`snippet: #1 [acorn] format 1`] = ` `; exports[`snippet: #1 [babel] format 1`] = ` -"Constructors in/after an Optional Chain are not allowed. (1:32) +"Constructors in/after an Optional Chain are not allowed. (1:22) > 1 | const safe5 = new obj?.qux?.baz(); // undefined - | ^" + | ^" `; exports[`snippet: #1 [espree] format 1`] = ` @@ -55,9 +55,9 @@ exports[`snippet: #2 [acorn] format 1`] = ` `; exports[`snippet: #2 [babel] format 1`] = ` -"Constructors in/after an Optional Chain are not allowed. (1:35) +"Constructors in/after an Optional Chain are not allowed. (1:22) > 1 | const safe6 = new obj?.foo.bar.qux?.(); // undefined - | ^" + | ^" `; exports[`snippet: #2 [espree] format 1`] = ` @@ -79,9 +79,9 @@ exports[`snippet: #3 [acorn] format 1`] = ` `; exports[`snippet: #3 [babel] format 1`] = ` -"Constructors in/after an Optional Chain are not allowed. (1:39) +"Constructors in/after an Optional Chain are not allowed. (1:26) > 1 | const willThrow = new obj?.foo.bar.qux(); // Error: not a constructor - | ^" + | ^" `; exports[`snippet: #3 [espree] format 1`] = ` @@ -105,11 +105,11 @@ exports[`snippet: #4 [acorn] format 1`] = ` `; exports[`snippet: #4 [babel] format 1`] = ` -"Constructors in/after an Optional Chain are not allowed. (4:11) +"Constructors in/after an Optional Chain are not allowed. (4:9) 2 | class Test { 3 | } > 4 | new Test?.(); // test instance - | ^" + | ^" `; exports[`snippet: #4 [espree] format 1`] = ` @@ -135,9 +135,9 @@ exports[`snippet: #5 [acorn] format 1`] = ` `; exports[`snippet: #5 [babel] format 1`] = ` -"Constructors in/after an Optional Chain are not allowed. (1:13) +"Constructors in/after an Optional Chain are not allowed. (1:11) > 1 | new exists?.(); // undefined - | ^" + | ^" `; exports[`snippet: #5 [espree] format 1`] = ` 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 db01346e1c7d..39543b69da08 100644 --- a/tests/format/misc/typescript-only/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/misc/typescript-only/__snapshots__/jsfmt.spec.js.snap @@ -355,15 +355,18 @@ class Foo { =====================================output===================================== class Foo { - accessor ["bar"] + accessor; + ["bar"] } class Foo { - static accessor bar + static accessor; + bar } class Foo { - accessor bar + accessor; + bar } ================================================================================ @@ -392,15 +395,18 @@ class Foo { =====================================output===================================== class Foo { - accessor ["bar"]; + accessor; + ["bar"]; } class Foo { - static accessor bar; + static accessor; + bar; } class Foo { - accessor bar; + accessor; + bar; } ================================================================================ diff --git a/tests/format/typescript/decorators/__snapshots__/jsfmt.spec.js.snap b/tests/format/typescript/decorators/__snapshots__/jsfmt.spec.js.snap index 691f9352ddcd..97157ebd0b56 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"] @@ -37,6 +104,28 @@ class Foo { ================================================================================ `; +exports[`comments.ts format 1`] = ` +====================================options===================================== +parsers: ["typescript"] +printWidth: 80 + | printWidth +=====================================input====================================== +class Something { + @Annotateme() + // comment + static property: Array; +} + +=====================================output===================================== +class Something { + @Annotateme() + // comment + static property: Array; +} + +================================================================================ +`; + exports[`decorator-type-assertion.ts format 1`] = ` ====================================options===================================== parsers: ["typescript"] @@ -256,12 +345,6 @@ class Something2 { abstract property: Array } -class Something3 { - @foo() - // comment - abstract method(): Array -} - =====================================output===================================== class Foo1 { @foo @@ -299,12 +382,6 @@ class Something2 { abstract property: Array; } -class Something3 { - @foo() - // comment - abstract method(): Array; -} - ================================================================================ `; @@ -419,3 +496,97 @@ class MyContainerComponent { ================================================================================ `; + +exports[`mobx.ts format 1`] = ` +====================================options===================================== +parsers: ["typescript"] +printWidth: 80 + | printWidth +=====================================input====================================== +import {observable} from "mobx"; + +@observer class OrderLine { + @observable price:number = 0; + @observable amount:number = 1; + + constructor(price) { + this.price = price; + } + + @computed get total() { + return this.price * this.amount; + } + + @action.bound setPrice(price) { + this.price = price; + } + + @computed + get total2() { + return this.price * this.amount; + } + + @action.bound + setPrice(price) { + this.price = price; + } + + @computed @computed @computed @computed @computed @computed @computed get total3() { + return this.price * this.amount; + } + + @action handleDecrease = (event: React.ChangeEvent) => this.count--; + + @action handleSomething = (event: React.ChangeEvent) => doSomething(); +} + +=====================================output===================================== +import { observable } from "mobx"; + +@observer +class OrderLine { + @observable price: number = 0; + @observable amount: number = 1; + + constructor(price) { + this.price = price; + } + + @computed get total() { + return this.price * this.amount; + } + + @action.bound setPrice(price) { + this.price = price; + } + + @computed + get total2() { + return this.price * this.amount; + } + + @action.bound + setPrice(price) { + this.price = price; + } + + @computed + @computed + @computed + @computed + @computed + @computed + @computed + get total3() { + return this.price * this.amount; + } + + @action handleDecrease = (event: React.ChangeEvent) => + this.count--; + + @action handleSomething = (event: React.ChangeEvent) => + doSomething(); +} + +================================================================================ +`; 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/comments.ts b/tests/format/typescript/decorators/comments.ts new file mode 100644 index 000000000000..f28b803b77ec --- /dev/null +++ b/tests/format/typescript/decorators/comments.ts @@ -0,0 +1,5 @@ +class Something { + @Annotateme() + // comment + static property: Array; +} 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 2ea3bb6eb2e4..3e59a6c31678 100644 --- a/tests/format/typescript/decorators/jsfmt.spec.js +++ b/tests/format/typescript/decorators/jsfmt.spec.js @@ -1 +1,3 @@ -run_spec(__dirname, ["typescript"]); +run_spec(__dirname, ["typescript"], { + errors: { typescript: ["abstract-method.ts", "accessor.ts"] }, +}); diff --git a/tests/format/typescript/decorators/mobx.ts b/tests/format/typescript/decorators/mobx.ts new file mode 100644 index 000000000000..9cab0ed72810 --- /dev/null +++ b/tests/format/typescript/decorators/mobx.ts @@ -0,0 +1,36 @@ +import {observable} from "mobx"; + +@observer class OrderLine { + @observable price:number = 0; + @observable amount:number = 1; + + constructor(price) { + this.price = price; + } + + @computed get total() { + return this.price * this.amount; + } + + @action.bound setPrice(price) { + this.price = price; + } + + @computed + get total2() { + return this.price * this.amount; + } + + @action.bound + setPrice(price) { + this.price = price; + } + + @computed @computed @computed @computed @computed @computed @computed get total3() { + return this.price * this.amount; + } + + @action handleDecrease = (event: React.ChangeEvent) => this.count--; + + @action handleSomething = (event: React.ChangeEvent) => doSomething(); +} diff --git a/tests/format/typescript/export/__snapshots__/jsfmt.spec.js.snap b/tests/format/typescript/export/__snapshots__/jsfmt.spec.js.snap index 440294152e25..f71a5c3bccfb 100644 --- a/tests/format/typescript/export/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/typescript/export/__snapshots__/jsfmt.spec.js.snap @@ -93,3 +93,46 @@ export default abstract class D {} ================================================================================ `; + +exports[`export-type-star-from.ts format 1`] = ` +====================================options===================================== +parsers: ["typescript"] +printWidth: 80 + | printWidth +=====================================input====================================== +export type * from './mod'; +export type * as ns from './mod'; + +=====================================output===================================== +export type * from "./mod"; +export type * as ns from "./mod"; + +================================================================================ +`; + +exports[`export-type-star-from-2.ts [babel-ts] format 1`] = ` +====================================options===================================== +parsers: ["typescript"] +printWidth: 80 + | printWidth +=====================================input====================================== +// Note: TSC doesn't support string module specifiers yet, +// but it's easier for us to support them than not. +export type * as "ns2" from './mod'; + +=====================================output===================================== +// Note: TSC doesn't support string module specifiers yet, +// but it's easier for us to support them than not. +export type * as "ns2" from "./mod"; + +================================================================================ +`; + +exports[`export-type-star-from-2.ts [typescript] format 1`] = ` +"Identifier expected. (3:18) + 1 | // Note: TSC doesn't support string module specifiers yet, + 2 | // but it's easier for us to support them than not. +> 3 | export type * as "ns2" from './mod'; + | ^ + 4 |" +`; diff --git a/tests/format/typescript/export/export-type-star-from-2.ts b/tests/format/typescript/export/export-type-star-from-2.ts new file mode 100644 index 000000000000..4f99f5f56ba7 --- /dev/null +++ b/tests/format/typescript/export/export-type-star-from-2.ts @@ -0,0 +1,3 @@ +// Note: TSC doesn't support string module specifiers yet, +// but it's easier for us to support them than not. +export type * as "ns2" from './mod'; diff --git a/tests/format/typescript/export/export-type-star-from.ts b/tests/format/typescript/export/export-type-star-from.ts new file mode 100644 index 000000000000..467b9869f96b --- /dev/null +++ b/tests/format/typescript/export/export-type-star-from.ts @@ -0,0 +1,2 @@ +export type * from './mod'; +export type * as ns from './mod'; diff --git a/tests/format/typescript/export/jsfmt.spec.js b/tests/format/typescript/export/jsfmt.spec.js index 2ea3bb6eb2e4..6c585bb260e6 100644 --- a/tests/format/typescript/export/jsfmt.spec.js +++ b/tests/format/typescript/export/jsfmt.spec.js @@ -1 +1,3 @@ -run_spec(__dirname, ["typescript"]); +run_spec(__dirname, ["typescript"], { + errors: { typescript: ["export-type-star-from-2.ts"] }, +}); 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 c658fae54521..43e06f60cdd0 100644 --- a/tests/format/typescript/typeparams/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/typescript/typeparams/__snapshots__/jsfmt.spec.js.snap @@ -286,6 +286,82 @@ const appIDs = createSelector( ================================================================================ `; +exports[`const.ts format 1`] = ` +====================================options===================================== +parsers: ["typescript"] +printWidth: 80 + | printWidth +=====================================input====================================== +function a() {} +function b() {} +function c() {} +declare function d(); +() => {}; +() => {}; +(function () {}); +(function () {}); +(function () {}); + +class A {} +class B {} +class C {} +class D {} +class E {} +(class {}); +(class {}); +(class {}); +(class {}); +(class {}); + +interface I {} +interface J {} +interface K {} +interface L {} +interface M {} + +class _ { + method() {} + method() {} + method() {} +} + +=====================================output===================================== +function a() {} +function b() {} +function c() {} +declare function d(); +() => {}; +() => {}; +(function () {}); +(function () {}); +(function () {}); + +class A {} +class B {} +class C {} +class D {} +class E {} +(class {}); +(class {}); +(class {}); +(class {}); +(class {}); + +interface I {} +interface J {} +interface K {} +interface L {} +interface M {} + +class _ { + method() {} + method() {} + method() {} +} + +================================================================================ +`; + exports[`long-function-arg.ts format 1`] = ` ====================================options===================================== parsers: ["typescript"] diff --git a/tests/format/typescript/typeparams/const.ts b/tests/format/typescript/typeparams/const.ts new file mode 100644 index 000000000000..8134608f85e4 --- /dev/null +++ b/tests/format/typescript/typeparams/const.ts @@ -0,0 +1,32 @@ +function a() {} +function b() {} +function c() {} +declare function d(); +() => {}; +() => {}; +(function () {}); +(function () {}); +(function () {}); + +class A {} +class B {} +class C {} +class D {} +class E {} +(class {}); +(class {}); +(class {}); +(class {}); +(class {}); + +interface I {} +interface J {} +interface K {} +interface L {} +interface M {} + +class _ { + method() {} + method() {} + method() {} +} diff --git a/yarn.lock b/yarn.lock index 2d4857916544..8d06b56738d2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,7 +2,7 @@ # yarn lockfile v1 -"@ampproject/remapping@^2.1.0": +"@ampproject/remapping@^2.1.0", "@ampproject/remapping@^2.2.0": version "2.2.0" resolved "https://registry.yarnpkg.com/@ampproject/remapping/-/remapping-2.2.0.tgz#56c133824780de3174aed5ab6834f3026790154d" integrity sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w== @@ -36,7 +36,28 @@ resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.20.10.tgz#9d92fa81b87542fff50e848ed585b4212c1d34ec" integrity sha512-sEnuDPpOJR/fcafHMjpcpGN5M2jbUGUHwmuWKM/YdPzeEDJg8bgmbcWQFUfE32MQjti1koACvoPVsDe8Uq+idg== -"@babel/core@7.20.7", "@babel/core@^7.1.0", "@babel/core@^7.12.3", "@babel/core@^7.7.2", "@babel/core@^7.8.0": +"@babel/core@7.21.3": + version "7.21.3" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.21.3.tgz#cf1c877284a469da5d1ce1d1e53665253fae712e" + integrity sha512-qIJONzoa/qiHghnm0l1n4i/6IIziDpzqc36FBs4pzMhDUraHqponwJLiAKm1hGLP3OSB/TVNz6rMwVGpwxxySw== + dependencies: + "@ampproject/remapping" "^2.2.0" + "@babel/code-frame" "^7.18.6" + "@babel/generator" "^7.21.3" + "@babel/helper-compilation-targets" "^7.20.7" + "@babel/helper-module-transforms" "^7.21.2" + "@babel/helpers" "^7.21.0" + "@babel/parser" "^7.21.3" + "@babel/template" "^7.20.7" + "@babel/traverse" "^7.21.3" + "@babel/types" "^7.21.3" + convert-source-map "^1.7.0" + debug "^4.1.0" + gensync "^1.0.0-beta.2" + json5 "^2.2.2" + semver "^6.3.0" + +"@babel/core@^7.1.0", "@babel/core@^7.12.3", "@babel/core@^7.7.2", "@babel/core@^7.8.0": version "7.20.7" resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.20.7.tgz#37072f951bd4d28315445f66e0ec9f6ae0c8c35f" integrity sha512-t1ZjCluspe5DW24bn2Rr1CDb2v9rn/hROtg9a2tmd0+QYf4bsloYfLQzjG4qHPNMhWtKdGC33R5AxGR2Af2cBw== @@ -66,6 +87,16 @@ "@jridgewell/gen-mapping" "^0.3.2" jsesc "^2.5.1" +"@babel/generator@^7.21.3": + version "7.21.3" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.21.3.tgz#232359d0874b392df04045d72ce2fd9bb5045fce" + integrity sha512-QS3iR1GYC/YGUnW7IdggFeN5c1poPUurnGttOV/bZgPGV+izC/D8HnD6DLwod0fsatNyVn1G3EVWMYIF0nHbeA== + dependencies: + "@babel/types" "^7.21.3" + "@jridgewell/gen-mapping" "^0.3.2" + "@jridgewell/trace-mapping" "^0.3.17" + jsesc "^2.5.1" + "@babel/helper-annotate-as-pure@^7.18.6": version "7.18.6" resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.18.6.tgz#eaa49f6f80d5a33f9a5dd2276e6d6e451be0a6bb" @@ -145,6 +176,14 @@ "@babel/template" "^7.18.10" "@babel/types" "^7.19.0" +"@babel/helper-function-name@^7.21.0": + version "7.21.0" + resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.21.0.tgz#d552829b10ea9f120969304023cd0645fa00b1b4" + integrity sha512-HfK1aMRanKHpxemaY2gqBmL04iAPOPRj7DxtNbiDOrJK+gdwkiNRVpCpUJYbUT+aZyemKN8brqTOxzCaG6ExRg== + dependencies: + "@babel/template" "^7.20.7" + "@babel/types" "^7.21.0" + "@babel/helper-hoist-variables@^7.18.6": version "7.18.6" resolved "https://registry.yarnpkg.com/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz#d4d2c8fb4baeaa5c68b99cc8245c56554f926678" @@ -180,6 +219,20 @@ "@babel/traverse" "^7.20.7" "@babel/types" "^7.20.7" +"@babel/helper-module-transforms@^7.21.2": + version "7.21.2" + resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.21.2.tgz#160caafa4978ac8c00ac66636cb0fa37b024e2d2" + integrity sha512-79yj2AR4U/Oqq/WOV7Lx6hUjau1Zfo4cI+JLAVYeMV5XIlbOhmjEk5ulbTc9fMpmlojzZHkUUxAiK+UKn+hNQQ== + dependencies: + "@babel/helper-environment-visitor" "^7.18.9" + "@babel/helper-module-imports" "^7.18.6" + "@babel/helper-simple-access" "^7.20.2" + "@babel/helper-split-export-declaration" "^7.18.6" + "@babel/helper-validator-identifier" "^7.19.1" + "@babel/template" "^7.20.7" + "@babel/traverse" "^7.21.2" + "@babel/types" "^7.21.2" + "@babel/helper-optimise-call-expression@^7.18.6": version "7.18.6" resolved "https://registry.yarnpkg.com/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.18.6.tgz#9369aa943ee7da47edab2cb4e838acf09d290ffe" @@ -269,6 +322,15 @@ "@babel/traverse" "^7.20.7" "@babel/types" "^7.20.7" +"@babel/helpers@^7.21.0": + version "7.21.0" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.21.0.tgz#9dd184fb5599862037917cdc9eecb84577dc4e7e" + integrity sha512-XXve0CBtOW0pd7MRzzmoyuSj0e3SEzj8pgyFxnTT1NJZL38BD1MK7yYrm8yefRPIDvNNe14xR4FdbHwpInD4rA== + dependencies: + "@babel/template" "^7.20.7" + "@babel/traverse" "^7.21.0" + "@babel/types" "^7.21.0" + "@babel/highlight@^7.0.0", "@babel/highlight@^7.18.6": version "7.18.6" resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.18.6.tgz#81158601e93e2563795adcbfbdf5d64be3f2ecdf" @@ -278,7 +340,12 @@ chalk "^2.0.0" js-tokens "^4.0.0" -"@babel/parser@7.20.7", "@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.20.7": +"@babel/parser@7.21.3", "@babel/parser@^7.21.3": + version "7.21.3" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.21.3.tgz#1d285d67a19162ff9daa358d4cb41d50c06220b3" + integrity sha512-lobG0d7aOfQRXh8AyklEAgZGvA4FShxo6xQbUrrT/cNBPUdIDojlokwJsQyCC/eKia7ifqM0yP+2DRZ4WKw2RQ== + +"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.20.7": version "7.20.7" resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.20.7.tgz#66fe23b3c8569220817d5feb8b9dcdc95bb4f71b" integrity sha512-T3Z9oHybU+0vZlY9CiDSJQTD5ZapcW18ZctFMi0MOAl/4BjFF4ul7NVSARLdbGO5vDqy9eQiGTV0LtKfvCYvcg== @@ -929,6 +996,22 @@ debug "^4.1.0" globals "^11.1.0" +"@babel/traverse@^7.21.0", "@babel/traverse@^7.21.2", "@babel/traverse@^7.21.3": + version "7.21.3" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.21.3.tgz#4747c5e7903d224be71f90788b06798331896f67" + integrity sha512-XLyopNeaTancVitYZe2MlUEvgKb6YVVPXzofHgqHijCImG33b/uTurMS488ht/Hbsb2XK3U2BnSTxKVNGV3nGQ== + dependencies: + "@babel/code-frame" "^7.18.6" + "@babel/generator" "^7.21.3" + "@babel/helper-environment-visitor" "^7.18.9" + "@babel/helper-function-name" "^7.21.0" + "@babel/helper-hoist-variables" "^7.18.6" + "@babel/helper-split-export-declaration" "^7.18.6" + "@babel/parser" "^7.21.3" + "@babel/types" "^7.21.3" + debug "^4.1.0" + globals "^11.1.0" + "@babel/types@7.20.7", "@babel/types@^7.0.0", "@babel/types@^7.18.6", "@babel/types@^7.18.9", "@babel/types@^7.19.0", "@babel/types@^7.20.0", "@babel/types@^7.20.2", "@babel/types@^7.20.5", "@babel/types@^7.20.7", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4": version "7.20.7" resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.20.7.tgz#54ec75e252318423fc07fb644dc6a58a64c09b7f" @@ -938,6 +1021,15 @@ "@babel/helper-validator-identifier" "^7.19.1" to-fast-properties "^2.0.0" +"@babel/types@^7.21.0", "@babel/types@^7.21.2", "@babel/types@^7.21.3": + version "7.21.3" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.21.3.tgz#4865a5357ce40f64e3400b0f3b737dc6d4f64d05" + integrity sha512-sBGdETxC+/M4o/zKC0sl6sjWv62WFR/uzxrJ6uYyMLZOUlPnwzw0tKgVHOXxaAd5l2g8pEDM5RZ495GPQI77kg== + dependencies: + "@babel/helper-string-parser" "^7.19.4" + "@babel/helper-validator-identifier" "^7.19.1" + to-fast-properties "^2.0.0" + "@bcoe/v8-coverage@^0.2.3": version "0.2.3" resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" @@ -1317,6 +1409,18 @@ resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.16.10.tgz#0e9c6a5e69c10d96aff2386b7ee9646138c2a831" integrity sha512-qddWullt3sC1EIpfHvCRBq3H4g3L86DZpD6n8k2XFjFVyp01D++uNbN1hT/JRsHxTbyyemZcpwL5aRlJwc/zFw== +"@eslint-community/eslint-utils@^4.2.0": + version "4.2.0" + resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.2.0.tgz#a831e6e468b4b2b5ae42bf658bea015bf10bc518" + integrity sha512-gB8T4H4DEfX2IV9zGDJPOBgP1e/DbfCPDTtEqUMckpvzS1OYtva8JdFYBqMwYk7xAQ429WGF/UPqn8uQ//h2vQ== + dependencies: + eslint-visitor-keys "^3.3.0" + +"@eslint-community/regexpp@^4.4.0": + version "4.4.0" + resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.4.0.tgz#3e61c564fcd6b921cb789838631c5ee44df09403" + integrity sha512-A9983Q0LnDGdLPjxyXQ00sbV+K+O+ko2Dr+CZigbHWtX9pNfxlaBkMR8X1CztI73zuEyEBXTVjx7CE+/VSwDiQ== + "@eslint/eslintrc@^1.4.0": version "1.4.0" resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.4.0.tgz#8ec64e0df3e7a1971ee1ff5158da87389f167a63" @@ -1635,7 +1739,7 @@ resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24" integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw== -"@jridgewell/trace-mapping@^0.3.9": +"@jridgewell/trace-mapping@^0.3.17", "@jridgewell/trace-mapping@^0.3.9": version "0.3.17" resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.17.tgz#793041277af9073b0951a7fe0f0d8c4c98c36985" integrity sha512-MCNzAp77qzKca9+W/+I0+sEpaUnZoeasnghNeVc41VZCEKaCH73Vq3BZZ/SzWIgrqE4H4ceI+p+b6C0mHf9T4g== @@ -1839,29 +1943,22 @@ dependencies: "@types/yargs-parser" "*" -"@typescript-eslint/eslint-plugin@5.36.2": - version "5.36.2" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.36.2.tgz#6df092a20e0f9ec748b27f293a12cb39d0c1fe4d" - integrity sha512-OwwR8LRwSnI98tdc2z7mJYgY60gf7I9ZfGjN5EjCwwns9bdTuQfAXcsjSB2wSQ/TVNYSGKf4kzVXbNGaZvwiXw== +"@typescript-eslint/eslint-plugin@5.55.0": + version "5.55.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.55.0.tgz#bc2400c3a23305e8c9a9c04aa40933868aaaeb47" + integrity sha512-IZGc50rtbjk+xp5YQoJvmMPmJEYoC53SiKPXyqWfv15XoD2Y5Kju6zN0DwlmaGJp1Iw33JsWJcQ7nw0lGCGjVg== dependencies: - "@typescript-eslint/scope-manager" "5.36.2" - "@typescript-eslint/type-utils" "5.36.2" - "@typescript-eslint/utils" "5.36.2" + "@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" - functional-red-black-tree "^1.0.1" + grapheme-splitter "^1.0.4" ignore "^5.2.0" - regexpp "^3.2.0" + natural-compare-lite "^1.4.0" semver "^7.3.7" tsutils "^3.21.0" -"@typescript-eslint/scope-manager@5.36.2": - version "5.36.2" - resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.36.2.tgz#a75eb588a3879ae659514780831370642505d1cd" - integrity sha512-cNNP51L8SkIFSfce8B1NSUBTJTu2Ts4nWeWbFrdaqjmn9yKrAaJUBHkyTZc0cL06OFHpb+JZq5AUHROS398Orw== - dependencies: - "@typescript-eslint/types" "5.36.2" - "@typescript-eslint/visitor-keys" "5.36.2" - "@typescript-eslint/scope-manager@5.47.0": version "5.47.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.47.0.tgz#f58144a6b0ff58b996f92172c488813aee9b09df" @@ -1870,81 +1967,73 @@ "@typescript-eslint/types" "5.47.0" "@typescript-eslint/visitor-keys" "5.47.0" -"@typescript-eslint/type-utils@5.36.2": - version "5.36.2" - resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.36.2.tgz#752373f4babf05e993adf2cd543a763632826391" - integrity sha512-rPQtS5rfijUWLouhy6UmyNquKDPhQjKsaKH0WnY6hl/07lasj8gPaH2UD8xWkePn6SC+jW2i9c2DZVDnL+Dokw== +"@typescript-eslint/scope-manager@5.55.0": + version "5.55.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.55.0.tgz#e863bab4d4183ddce79967fe10ceb6c829791210" + integrity sha512-OK+cIO1ZGhJYNCL//a3ROpsd83psf4dUJ4j7pdNVzd5DmIk+ffkuUIX2vcZQbEW/IR41DYsfJTB19tpCboxQuw== + dependencies: + "@typescript-eslint/types" "5.55.0" + "@typescript-eslint/visitor-keys" "5.55.0" + +"@typescript-eslint/type-utils@5.55.0": + version "5.55.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.55.0.tgz#74bf0233523f874738677bb73cb58094210e01e9" + integrity sha512-ObqxBgHIXj8rBNm0yh8oORFrICcJuZPZTqtAFh0oZQyr5DnAHZWfyw54RwpEEH+fD8suZaI0YxvWu5tYE/WswA== dependencies: - "@typescript-eslint/typescript-estree" "5.36.2" - "@typescript-eslint/utils" "5.36.2" + "@typescript-eslint/typescript-estree" "5.55.0" + "@typescript-eslint/utils" "5.55.0" debug "^4.3.4" tsutils "^3.21.0" -"@typescript-eslint/types@5.36.2": - version "5.36.2" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.36.2.tgz#a5066e500ebcfcee36694186ccc57b955c05faf9" - integrity sha512-9OJSvvwuF1L5eS2EQgFUbECb99F0mwq501w0H0EkYULkhFa19Qq7WFbycdw1PexAc929asupbZcgjVIe6OK/XQ== - -"@typescript-eslint/types@5.45.0": - version "5.45.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.45.0.tgz#794760b9037ee4154c09549ef5a96599621109c5" - integrity sha512-QQij+u/vgskA66azc9dCmx+rev79PzX8uDHpsqSjEFtfF2gBUTRCpvYMh2gw2ghkJabNkPlSUCimsyBEQZd1DA== - "@typescript-eslint/types@5.47.0": version "5.47.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.47.0.tgz#67490def406eaa023dbbd8da42ee0d0c9b5229d3" integrity sha512-eslFG0Qy8wpGzDdYKu58CEr3WLkjwC5Usa6XbuV89ce/yN5RITLe1O8e+WFEuxnfftHiJImkkOBADj58ahRxSg== -"@typescript-eslint/typescript-estree@5.36.2": - version "5.36.2" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.36.2.tgz#0c93418b36c53ba0bc34c61fe9405c4d1d8fe560" - integrity sha512-8fyH+RfbKc0mTspfuEjlfqA4YywcwQK2Amcf6TDOwaRLg7Vwdu4bZzyvBZp4bjt1RRjQ5MDnOZahxMrt2l5v9w== - dependencies: - "@typescript-eslint/types" "5.36.2" - "@typescript-eslint/visitor-keys" "5.36.2" - debug "^4.3.4" - globby "^11.1.0" - is-glob "^4.0.3" - semver "^7.3.7" - tsutils "^3.21.0" +"@typescript-eslint/types@5.55.0": + version "5.55.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.55.0.tgz#9830f8d3bcbecf59d12f821e5bc6960baaed41fd" + integrity sha512-M4iRh4AG1ChrOL6Y+mETEKGeDnT7Sparn6fhZ5LtVJF1909D5O4uqK+C5NPbLmpfZ0XIIxCdwzKiijpZUOvOug== -"@typescript-eslint/typescript-estree@5.45.0": - version "5.45.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.45.0.tgz#f70a0d646d7f38c0dfd6936a5e171a77f1e5291d" - integrity sha512-maRhLGSzqUpFcZgXxg1qc/+H0bT36lHK4APhp0AEUVrpSwXiRAomm/JGjSG+kNUio5kAa3uekCYu/47cnGn5EQ== +"@typescript-eslint/typescript-estree@5.47.0": + version "5.47.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.47.0.tgz#ed971a11c5c928646d6ba7fc9dfdd6e997649aca" + integrity sha512-LxfKCG4bsRGq60Sqqu+34QT5qT2TEAHvSCCJ321uBWywgE2dS0LKcu5u+3sMGo+Vy9UmLOhdTw5JHzePV/1y4Q== dependencies: - "@typescript-eslint/types" "5.45.0" - "@typescript-eslint/visitor-keys" "5.45.0" + "@typescript-eslint/types" "5.47.0" + "@typescript-eslint/visitor-keys" "5.47.0" debug "^4.3.4" globby "^11.1.0" is-glob "^4.0.3" semver "^7.3.7" tsutils "^3.21.0" -"@typescript-eslint/typescript-estree@5.47.0": - version "5.47.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.47.0.tgz#ed971a11c5c928646d6ba7fc9dfdd6e997649aca" - integrity sha512-LxfKCG4bsRGq60Sqqu+34QT5qT2TEAHvSCCJ321uBWywgE2dS0LKcu5u+3sMGo+Vy9UmLOhdTw5JHzePV/1y4Q== +"@typescript-eslint/typescript-estree@5.55.0": + version "5.55.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.55.0.tgz#8db7c8e47ecc03d49b05362b8db6f1345ee7b575" + integrity sha512-I7X4A9ovA8gdpWMpr7b1BN9eEbvlEtWhQvpxp/yogt48fy9Lj3iE3ild/1H3jKBBIYj5YYJmS2+9ystVhC7eaQ== dependencies: - "@typescript-eslint/types" "5.47.0" - "@typescript-eslint/visitor-keys" "5.47.0" + "@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" semver "^7.3.7" tsutils "^3.21.0" -"@typescript-eslint/utils@5.36.2": - version "5.36.2" - resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.36.2.tgz#b01a76f0ab244404c7aefc340c5015d5ce6da74c" - integrity sha512-uNcopWonEITX96v9pefk9DC1bWMdkweeSsewJ6GeC7L6j2t0SJywisgkr9wUTtXk90fi2Eljj90HSHm3OGdGRg== +"@typescript-eslint/utils@5.55.0": + version "5.55.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.55.0.tgz#34e97322e7ae5b901e7a870aabb01dad90023341" + integrity sha512-FkW+i2pQKcpDC3AY6DU54yl8Lfl14FVGYDgBTyGKB75cCwV3KpkpTMFi9d9j2WAJ4271LR2HeC5SEWF/CZmmfw== dependencies: + "@eslint-community/eslint-utils" "^4.2.0" "@types/json-schema" "^7.0.9" - "@typescript-eslint/scope-manager" "5.36.2" - "@typescript-eslint/types" "5.36.2" - "@typescript-eslint/typescript-estree" "5.36.2" + "@types/semver" "^7.3.12" + "@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" "@typescript-eslint/utils@^5.10.0": version "5.47.0" @@ -1960,22 +2049,6 @@ eslint-utils "^3.0.0" semver "^7.3.7" -"@typescript-eslint/visitor-keys@5.36.2": - version "5.36.2" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.36.2.tgz#2f8f78da0a3bad3320d2ac24965791ac39dace5a" - integrity sha512-BtRvSR6dEdrNt7Net2/XDjbYKU5Ml6GqJgVfXT0CxTCJlnIqK7rAGreuWKMT2t8cFUT2Msv5oxw0GMRD7T5J7A== - dependencies: - "@typescript-eslint/types" "5.36.2" - eslint-visitor-keys "^3.3.0" - -"@typescript-eslint/visitor-keys@5.45.0": - version "5.45.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.45.0.tgz#e0d160e9e7fdb7f8da697a5b78e7a14a22a70528" - integrity sha512-jc6Eccbn2RtQPr1s7th6jJWQHBHI6GBVQkCHoJFQ5UreaKm59Vxw+ynQUPPY2u2Amquc+7tmEoC2G52ApsGNNg== - dependencies: - "@typescript-eslint/types" "5.45.0" - eslint-visitor-keys "^3.3.0" - "@typescript-eslint/visitor-keys@5.47.0": version "5.47.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.47.0.tgz#4aca4efbdf6209c154df1f7599852d571b80bb45" @@ -1984,6 +2057,14 @@ "@typescript-eslint/types" "5.47.0" eslint-visitor-keys "^3.3.0" +"@typescript-eslint/visitor-keys@5.55.0": + version "5.55.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.55.0.tgz#01ad414fca8367706d76cdb94adf788dc5b664a2" + integrity sha512-q2dlHHwWgirKh1D3acnuApXG+VNXpEY5/AwRxDVuEQpxWaB0jCDe0jFMVMALJ3ebSfuOVE8/rMS+9ZOYGg1GWw== + dependencies: + "@typescript-eslint/types" "5.55.0" + eslint-visitor-keys "^3.3.0" + abab@^2.0.3, abab@^2.0.5: version "2.0.6" resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.6.tgz#41b80f2c871d19686216b82309231cfd3cb3d291" @@ -3569,11 +3650,6 @@ function.prototype.name@^1.1.5: es-abstract "^1.19.0" functions-have-names "^1.2.2" -functional-red-black-tree@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" - integrity sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g== - functions-have-names@^1.2.2: version "1.2.3" resolved "https://registry.yarnpkg.com/functions-have-names/-/functions-have-names-1.2.3.tgz#0404fe4ee2ba2f607f0e0ec3c80bae994133b834" @@ -4710,6 +4786,11 @@ json5@^1.0.1: dependencies: minimist "^1.2.0" +json5@^2.2.2: + version "2.2.3" + resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" + integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== + jsonfile@^6.0.1: version "6.1.0" resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae" @@ -5008,6 +5089,11 @@ n-readlines@1.0.1: resolved "https://registry.yarnpkg.com/n-readlines/-/n-readlines-1.0.1.tgz#bbb7364d38bc31a170a199f986fcacfa76b95f6e" integrity sha512-z4SyAIVgMy7CkgsoNw7YVz40v0g4+WWvvqy8+ZdHrCtgevcEO758WQyrYcw3XPxcLxF+//RszTz/rO48nzD0wQ== +natural-compare-lite@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz#17b09581988979fddafe0201e931ba933c96cbb4" + integrity sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g== + natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" @@ -6425,10 +6511,10 @@ typedarray-to-buffer@^3.1.5: dependencies: is-typedarray "^1.0.0" -typescript@4.9.3: - version "4.9.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.3.tgz#3aea307c1746b8c384435d8ac36b8a2e580d85db" - integrity sha512-CIfGzTelbKNEnLpLdGFgdyKhG23CKdKgQPOBc+OUNrkJ2vr+KSzsSV5kq5iWhEQbok+quxgGzrAtGWCyU7tHnA== +typescript@5.0.2: + version "5.0.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.2.tgz#891e1a90c5189d8506af64b9ef929fca99ba1ee5" + integrity sha512-wVORMBGO/FAs/++blGNeAVdbNKtIh1rbBL2EyQ1+J9lClJ93KiiKe8PmFIVdXhHcyv44SL9oglmfeSsndo0jRw== unbox-primitive@^1.0.2: version "1.0.2"