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/package.json b/package.json index 130a2e80ed66..e471485ed1a4 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "@prettier/is-es5-identifier-name": "0.1.0", "@prettier/parse-srcset": "2.0.2", "@typescript-eslint/typescript-estree": "5.55.0", - "@typescript-eslint/visitor-keys": "5.54.1", + "@typescript-eslint/visitor-keys": "5.55.0", "acorn": "8.8.2", "acorn-jsx": "5.3.2", "angular-estree-parser": "6.0.0", diff --git a/scripts/build/modify-typescript-module.mjs b/scripts/build/modify-typescript-module.mjs index 762222267d03..5ab60a80f0b3 100644 --- a/scripts/build/modify-typescript-module.mjs +++ b/scripts/build/modify-typescript-module.mjs @@ -129,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() { @@ -162,79 +162,21 @@ function modifyTypescriptModule(text) { } } - // 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;") - ); + // jsTyping + for (const module of source.modules) { + if (module.path.startsWith("src/jsTyping/")) { + source.removeModule(module); + } + } - // `ts.getScriptTargetFeatures` - source - .replaceAlignedCode({ - start: "function getScriptTargetFeatures(", - end: "}", - }) - .replace("ts.getScriptTargetFeatures = getScriptTargetFeatures;", ""); + // services + for (const module of source.modules) { + if ( + module.path === "src/services/services.ts" || + module.path === "src/services/_namespaces/ts.ts" + ) { + continue; + } // This is a big module, most code except `scanner` is not used if (module.path === "src/services/utilities.ts") { @@ -251,233 +193,18 @@ function modifyTypescriptModule(text) { continue; } - // `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;") - ); - - // `ts.transformNodes` and more - source.removeSubmodule((text) => - text.includes("ts.transformNodes = transformNodes;") - ); - - // `ts.server` - source.removeSubmodule((text) => text.includes("(ts.server = {})")); - - // `ts.JsTyping` - source.removeSubmodule((text) => text.includes("(ts.JsTyping = {})")); - - // `ts.ClassificationType` - source.removeSubmodule((text) => - text.includes("(ts.ClassificationType = {})") - ); - - // 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;") - ); - - // 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;") - ); - - // `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.removeModule("src/compiler/_namespaces/ts.moduleSpecifiers.ts"); @@ -531,17 +258,15 @@ function modifyTypescriptModule(text) { ` ); - source.replaceAlignedCode({ - start: "var debugObjectHost = (function () {", - end: "})();", - }); - - // TODO[@fisker]: investigate possible `magic-string` bug - source.applyChanges(); - - for (const [find, replacement] of Object.entries({ - // yarn pnp - "process.versions.pnp": "undefined", + // `factory` + source.removeModule("src/compiler/factory/emitNode.ts"); + source.removeModule("src/compiler/factory/emitHelpers.ts"); + source.replaceModule( + "src/compiler/factory/nodeConverters.ts", + outdent` + var createNodeConverters = () => new Proxy({}, {get: () => () => {}}); + ` + ); /* spell-checker: disable */ // `ts.createParenthesizerRules` @@ -551,6 +276,18 @@ function modifyTypescriptModule(text) { }); /* spell-checker: enable */ + source.replaceAlignedCode({ + start: "function getScriptTargetFeatures(", + end: "}", + }); + + source.replaceAlignedCode({ + start: "var __require = ", + end: "});", + }); + + 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 c7d7702385eb..3f9ec7719fef 100644 --- a/src/language-js/print/class.js +++ b/src/language-js/print/class.js @@ -297,11 +297,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/ignore/__snapshots__/jsfmt.spec.js.snap b/tests/format/js/ignore/__snapshots__/jsfmt.spec.js.snap index 3483b0b63094..975572cca185 100644 --- a/tests/format/js/ignore/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/js/ignore/__snapshots__/jsfmt.spec.js.snap @@ -33,6 +33,17 @@ exports[`class-expression-decorator.js [flow] format 1`] = ` 6 |" `; +exports[`class-expression-decorator.js [typescript] format 1`] = ` +"Decorators are not valid here. (3:3) + 1 | ( + 2 | // prettier-ignore +> 3 | @decorator + | ^^^^^^^^^^ + 4 | class {} + 5 | ); + 6 |" +`; + exports[`class-expression-decorator.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] diff --git a/tests/format/js/ignore/jsfmt.spec.js b/tests/format/js/ignore/jsfmt.spec.js index 95ad5bb38b74..2029485ddc7b 100644 --- a/tests/format/js/ignore/jsfmt.spec.js +++ b/tests/format/js/ignore/jsfmt.spec.js @@ -3,5 +3,6 @@ run_spec(import.meta, ["babel", "flow", "typescript"], { acorn: ["decorator.js", "class-expression-decorator.js"], espree: ["decorator.js", "class-expression-decorator.js"], flow: ["class-expression-decorator.js"], + typescript: ["class-expression-decorator.js"], }, }); 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 bf81ee7232ed..a19e43da3c32 100644 --- a/tests/format/misc/typescript-only/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/misc/typescript-only/__snapshots__/jsfmt.spec.js.snap @@ -87,47 +87,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"] @@ -315,81 +274,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 3ef76705669b..d7771f91676d 100644 --- a/tests/format/typescript/decorators/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/typescript/decorators/__snapshots__/jsfmt.spec.js.snap @@ -537,7 +537,7 @@ class OrderLine { } @computed - get total() { + get total2() { return this.price * this.amount; } diff --git a/tests/format/typescript/decorators/jsfmt.spec.js b/tests/format/typescript/decorators/jsfmt.spec.js index b0280de1e775..d20e1c41ca3c 100644 --- a/tests/format/typescript/decorators/jsfmt.spec.js +++ b/tests/format/typescript/decorators/jsfmt.spec.js @@ -1,3 +1,6 @@ run_spec(import.meta, ["typescript"], { - errors: { typescript: ["abstract-method.ts"] }, + errors: { + typescript: ["abstract-method.ts", "accessor.ts"], + "babel-ts": ["issue-9102.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 409110a22a02..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 @@ -49,7 +49,7 @@ exports[`3.ts [typescript] format 1`] = ` 2 |" `; -exports[`4.ts format 1`] = ` +exports[`4.ts [babel-ts] format 1`] = ` ====================================options===================================== parsers: ["typescript"] printWidth: 80 @@ -66,6 +66,13 @@ printWidth: 80 ================================================================================ `; +exports[`4.ts [typescript] format 1`] = ` +"Decorators are not valid here. (1:2) +> 1 | (@f<(v: T) => void>() class {}); + | ^^^^^^^^^^^^^^^^^^^^^^^ + 2 |" +`; + exports[`5.tsx [babel-ts] format 1`] = ` ====================================options===================================== parsers: ["typescript"] diff --git a/tests/format/typescript/type-arguments-bit-shift-left-like/jsfmt.spec.js b/tests/format/typescript/type-arguments-bit-shift-left-like/jsfmt.spec.js index 5bab6c9b8d91..14bba5070558 100644 --- a/tests/format/typescript/type-arguments-bit-shift-left-like/jsfmt.spec.js +++ b/tests/format/typescript/type-arguments-bit-shift-left-like/jsfmt.spec.js @@ -1,3 +1,3 @@ run_spec(import.meta, ["typescript"], { - errors: { typescript: ["3.ts", "5.tsx"] }, + errors: { typescript: ["3.ts", "4.ts", "5.tsx"] }, }); 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 6bfd95bef893..be8242720f64 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1800,9 +1800,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 @@ -2112,16 +2112,6 @@ __metadata: 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" - dependencies: - "@typescript-eslint/types": 5.54.1 - "@typescript-eslint/visitor-keys": 5.54.1 - checksum: 9add24cf3a7852634ad0680a827646860ac4698a6ac8aae31e8b781e29f59e84b51f0cdaacffd0747811012647f01b51969d988da9b302ead374ceebffbe204b - languageName: node - linkType: hard - "@typescript-eslint/scope-manager@npm:5.55.0": version: 5.55.0 resolution: "@typescript-eslint/scope-manager@npm:5.55.0" @@ -2149,13 +2139,6 @@ __metadata: 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 - languageName: node - linkType: hard - "@typescript-eslint/types@npm:5.55.0": version: 5.55.0 resolution: "@typescript-eslint/types@npm:5.55.0" @@ -2163,24 +2146,6 @@ __metadata: 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" - dependencies: - "@typescript-eslint/types": 5.54.1 - "@typescript-eslint/visitor-keys": 5.54.1 - debug: ^4.3.4 - globby: ^11.1.0 - is-glob: ^4.0.3 - semver: ^7.3.7 - tsutils: ^3.21.0 - peerDependenciesMeta: - typescript: - optional: true - checksum: ea42bdb4832fa96fa1121237c9b664ac4506e2836646651e08a8542c8601d78af6c288779707f893ca4c884221829bb7d7b4b43c4a9c3ed959519266d03a139b - languageName: node - linkType: hard - "@typescript-eslint/typescript-estree@npm:5.55.0": version: 5.55.0 resolution: "@typescript-eslint/typescript-estree@npm:5.55.0" @@ -2221,13 +2186,13 @@ __metadata: version: 5.47.0 resolution: "@typescript-eslint/utils@npm:5.47.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 @@ -2235,16 +2200,6 @@ __metadata: 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" - dependencies: - "@typescript-eslint/types": 5.54.1 - eslint-visitor-keys: ^3.3.0 - checksum: 3a691abd2a43b86a0c41526d14a2afcc93a2e0512b5f8b9ec43f6029c493870808036eae5ee4fc655d26e1999017c4a4dffb241f47c36c2a1238ec9fbd08719c - languageName: node - linkType: hard - "@typescript-eslint/visitor-keys@npm:5.55.0": version: 5.55.0 resolution: "@typescript-eslint/visitor-keys@npm:5.55.0" @@ -3627,9 +3582,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 @@ -4299,11 +4254,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 @@ -4726,7 +4681,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: @@ -5232,13 +5187,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 @@ -7675,7 +7630,7 @@ __metadata: "@types/jest": 29.4.0 "@typescript-eslint/eslint-plugin": 5.55.0 "@typescript-eslint/typescript-estree": 5.55.0 - "@typescript-eslint/visitor-keys": 5.54.1 + "@typescript-eslint/visitor-keys": 5.55.0 acorn: 8.8.2 acorn-jsx: 5.3.2 angular-estree-parser: 6.0.0