diff --git a/package.json b/package.json index b39d9e2e4..c32d14b24 100644 --- a/package.json +++ b/package.json @@ -73,11 +73,11 @@ "fast-json-stable-stringify": "2.1.0", "file-entry-cache": "11.1.1", "find-cache-directory": "6.0.0", - "flow-parser": "0.291.0", + "flow-parser": "0.294.0", "get-east-asian-width": "1.4.0", "get-stdin": "9.0.0", "graphql": "16.12.0", - "hermes-parser": "0.32.1", + "hermes-parser": "0.33.0", "html-element-attributes": "3.5.0", "html-ua-styles": "0.2.0", "ignore": "7.0.5", diff --git a/src/language-js/comments/handle-comments.js b/src/language-js/comments/handle-comments.js index 0ac17076e..693ac8395 100644 --- a/src/language-js/comments/handle-comments.js +++ b/src/language-js/comments/handle-comments.js @@ -785,6 +785,7 @@ function handleUnionTypeComments({ } if (isUnionType(followingNode) && isPrettierIgnoreComment(comment)) { + // @ts-expect-error -- Fix me followingNode.types[0].prettierIgnore = true; comment.unignore = true; } diff --git a/src/language-js/parse/postprocess/index.js b/src/language-js/parse/postprocess/index.js index 3f25d93e1..03191e92c 100644 --- a/src/language-js/parse/postprocess/index.js +++ b/src/language-js/parse/postprocess/index.js @@ -165,6 +165,13 @@ function postprocess(ast, options) { node.options = node.attributes; } break; + + // babel-flow + case "TupleTypeAnnotation": + if (node.types && !node.elementTypes) { + node.elementTypes = node.types; + } + break; } }, onLeave(node) { diff --git a/src/language-js/print/array.js b/src/language-js/print/array.js index 83653c854..50eca790f 100644 --- a/src/language-js/print/array.js +++ b/src/language-js/print/array.js @@ -20,6 +20,7 @@ import { isNumericLiteral, isObjectExpression, isSignedNumericLiteral, + isTupleType, shouldPrintComma, } from "../utilities/index.js"; import { printOptionalToken } from "./miscellaneous.js"; @@ -55,13 +56,7 @@ function printArray(path, options, print) { const openBracket = "["; const closeBracket = "]"; - const elementsProperty = - // TODO: Remove `types` when babel changes AST of `TupleTypeAnnotation` - node.type === "TupleTypeAnnotation" && node.types - ? "types" - : node.type === "TSTupleType" || node.type === "TupleTypeAnnotation" - ? "elementTypes" - : "elements"; + const elementsProperty = isTupleType(node) ? "elementTypes" : "elements"; const elements = node[elementsProperty]; if (elements.length === 0) { parts.push( diff --git a/src/language-js/print/class.js b/src/language-js/print/class.js index 94253721a..774fa9f01 100644 --- a/src/language-js/print/class.js +++ b/src/language-js/print/class.js @@ -92,10 +92,7 @@ function printClass(path, options, print) { if (node.superClass) { const printed = [ printSuperClass(path, options, print), - print( - // TODO: Remove `superTypeParameters` when https://github.com/facebook/hermes/issues/1808#issuecomment-3413004377 get fixed - node.superTypeArguments ? "superTypeArguments" : "superTypeParameters", - ), + print("superTypeArguments"), ]; const printedWithComments = path.call( () => ["extends ", printComments(path, printed, options)], @@ -184,10 +181,7 @@ function shouldPrintClassInGroupModeWithoutCache(path) { return false; } - const superTypeArguments = - node.superTypeArguments ?? node.superTypeParameters; - - return !superTypeArguments && isMemberExpression(node.superClass); + return !node.superTypeArguments && isMemberExpression(node.superClass); } const heritage = diff --git a/src/language-js/print/union-type.js b/src/language-js/print/union-type.js index 4ab95f90d..ef54974eb 100644 --- a/src/language-js/print/union-type.js +++ b/src/language-js/print/union-type.js @@ -18,6 +18,7 @@ import { hasComment, hasLeadingOwnLineComment, isConditionalType, + isTupleType, isTypeAlias, shouldUnionTypePrintOwnComments, } from "../utilities/index.js"; @@ -47,8 +48,7 @@ function printUnionType(path, options, print) { parent.type !== "GenericTypeAnnotation" && parent.type !== "TSTypeReference" && parent.type !== "TSTypeAssertion" && - parent.type !== "TupleTypeAnnotation" && - parent.type !== "TSTupleType" && + !isTupleType(parent) && !( parent.type === "FunctionTypeParam" && !parent.name && @@ -108,25 +108,15 @@ function printUnionType(path, options, print) { const parts = [leading, group(mainParts)]; - if (parent.type === "TupleTypeAnnotation" || parent.type === "TSTupleType") { - const elementTypes = - parent[ - // TODO: Remove `types` when babel changes AST of `TupleTypeAnnotation` - parent.type === "TupleTypeAnnotation" && parent.types - ? "types" - : "elementTypes" - ]; - - if (elementTypes.length > 1) { - return [ - group([ - indent([ifBreak(["(", softline]), parts]), - softline, - ifBreak(")"), - ]), - trailing, - ]; - } + if (isTupleType(parent) && parent.elementTypes.length > 1) { + return [ + group([ + indent([ifBreak(["(", softline]), parts]), + softline, + ifBreak(")"), + ]), + trailing, + ]; } return [group(shouldIndent ? indent(parts) : parts), trailing]; diff --git a/src/language-js/traverse/visitor-keys.evaluate.js b/src/language-js/traverse/visitor-keys.evaluate.js index 5efaacd7c..047dfc041 100644 --- a/src/language-js/traverse/visitor-keys.evaluate.js +++ b/src/language-js/traverse/visitor-keys.evaluate.js @@ -3,6 +3,7 @@ import { visitorKeys as tsVisitorKeys } from "@typescript-eslint/visitor-keys"; import { visitorKeys as angularVisitorKeys } from "angular-estree-parser"; import flowVisitorKeys from "hermes-parser/dist/generated/ESTreeVisitorKeys.js"; import { + addVisitorKeys, generateReferenceSharedVisitorKeys, removeNodeTypes, removeVisitorKeys, @@ -21,22 +22,12 @@ const additionalVisitorKeys = { TSJSDocNullableType: ["typeAnnotation"], TSJSDocNonNullableType: ["typeAnnotation"], - // Flow, missed in `flowVisitorKeys` - NeverTypeAnnotation: [], + // Flow + // `SatisfiesExpression` is a private feature https://github.com/facebook/hermes/issues/1808#issuecomment-3392476828 SatisfiesExpression: ["expression", "typeAnnotation"], - TupleTypeAnnotation: ["elementTypes"], - UndefinedTypeAnnotation: [], - UnknownTypeAnnotation: [], }; const excludeVisitorKeys = { - // From `flowVisitorKeys` - ArrowFunctionExpression: ["id"], - - // TODO: Remove `types` when babel changes AST of `TupleTypeAnnotation` - // Flow parser changed `.types` to `.elementTypes` https://github.com/facebook/flow/commit/5b60e6a81dc277dfab2e88fa3737a4dc9aafdcab - // TupleTypeAnnotation: ["types"], - // Not supported yet. // https://github.com/facebook/hermes/commit/55a5f881361ef15fd4f7b558166d80e7b9086550 DeclareOpaqueType: ["impltype"], @@ -45,6 +36,9 @@ const excludeVisitorKeys = { ExportAllDeclaration: ["assertions"], ImportDeclaration: ["assertions"], + // Flow node from Babel + TupleTypeAnnotation: ["types"], + // https://github.com/babel/babel/issues/17506 TSImportType: ["argument"], }; @@ -61,6 +55,16 @@ const excludeNodeTypes = [ // https://github.com/typescript-eslint/typescript-eslint/blob/d2d7ace4e52bedf07482fd879d8e31a52b38fc26/packages/visitor-keys/tests/visitor-keys.test.ts#L14-L18 "ExperimentalRestProperty", "ExperimentalSpreadProperty", + + // Unsupported flow features + "MatchInstanceObjectPattern", + "MatchInstancePattern", + "RecordDeclaration", + "RecordDeclarationBody", + "RecordDeclarationImplements", + "RecordDeclarationProperty", + "RecordDeclarationStaticProperty", + "RecordExpressionProperties", ]; let visitorKeys = unionVisitorKeys( @@ -68,9 +72,9 @@ let visitorKeys = unionVisitorKeys( tsVisitorKeys, flowVisitorKeys, angularVisitorKeys, - additionalVisitorKeys, ); +visitorKeys = addVisitorKeys(visitorKeys, additionalVisitorKeys); visitorKeys = removeNodeTypes(visitorKeys, excludeNodeTypes); visitorKeys = removeVisitorKeys(visitorKeys, excludeVisitorKeys); diff --git a/src/language-js/types/babel.d.ts b/src/language-js/types/babel.d.ts new file mode 100644 index 000000000..8ae3c4372 --- /dev/null +++ b/src/language-js/types/babel.d.ts @@ -0,0 +1,4 @@ +import type * as Babel from "@babel/types"; + +export type * from "@babel/types"; +export type Node = Exclude; diff --git a/src/language-js/types/estree.d.ts b/src/language-js/types/estree.d.ts index cbfd9aaa7..c2d2bca78 100644 --- a/src/language-js/types/estree.d.ts +++ b/src/language-js/types/estree.d.ts @@ -1,8 +1,9 @@ -import type * as Babel from "@babel/types"; import type { ESTree as MeriyahESTree } from "meriyah"; +import type * as Babel from "@babel/types"; import type { NGTree } from "angular-estree-parser"; import type * as TSESTree from "./typescript-estree.ts"; import type * as FlowESTree from "./flow-estree.js"; +import type * as Babel from "./babel.js"; type PrettierNodeAdditionalProperties = { extra?: { @@ -19,15 +20,11 @@ type PrettierCommentAdditionalProperties = { leading?: boolean; }; -type FlowAdditionalNode = - | { - type: "SatisfiesExpression"; - expression: FlowESTree.Expression; - typeAnnotation: FlowESTree.TypeAnnotationType; - } - | { type: "NeverTypeAnnotation" } - | { type: "UndefinedTypeAnnotation" } - | { type: "UnknownTypeAnnotation" }; +type FlowAdditionalNode = { + type: "SatisfiesExpression"; + expression: FlowESTree.Expression; + typeAnnotation: FlowESTree.TypeAnnotationType; +}; type PrettierNode = { type: "JsExpressionRoot"; node: Babel.Expression }; @@ -42,9 +39,9 @@ export type Comment = ( type _Node = | PrettierNode - | Babel.Node + | Exclude | TSESTree.Node - | NGTree.NGNode + | Exclude | FlowESTree.ESNode | FlowAdditionalNode; diff --git a/src/language-js/types/flow-estree.d.ts b/src/language-js/types/flow-estree.d.ts index fd9dc4496..5b77430a4 100644 --- a/src/language-js/types/flow-estree.d.ts +++ b/src/language-js/types/flow-estree.d.ts @@ -210,8 +210,17 @@ export type ESNode = | MatchPattern | MatchRestPattern | MatchObjectPatternProperty + | MatchInstanceObjectPattern | MatchExpressionCase | MatchStatementCase + // Records + | RecordDeclaration + | RecordDeclarationImplements + | RecordDeclarationBody + | RecordDeclarationProperty + | RecordDeclarationStaticProperty + | RecordExpression + | RecordExpressionProperties // JSX | JSXNode; @@ -279,7 +288,8 @@ export type Statement = | VariableDeclaration | WhileStatement | WithStatement - | MatchStatement; + | MatchStatement + | RecordDeclaration; // nodes that can be the direct parent of a statement export type StatementParentSingle = @@ -489,6 +499,7 @@ export type Expression = | AsExpression | AsConstExpression | MatchExpression + | RecordExpression | JSXFragment | JSXElement; @@ -513,18 +524,24 @@ export interface ObjectExpression extends BaseNode { // and object desturcturing properties. export type Property = ObjectProperty | DestructuringObjectProperty; +export type ObjectPropertyKey = + | Identifier + | StringLiteral + | NumericLiteral + | BigIntLiteral; + export type ObjectProperty = | ObjectPropertyWithNonShorthandStaticName | ObjectPropertyWithShorthandStaticName | ObjectPropertyWithComputedName; interface ObjectPropertyBase extends BaseNode { - parent: ObjectExpression | ObjectPattern; + parent: ObjectExpression | ObjectPattern | RecordExpressionProperties; } export interface ObjectPropertyWithNonShorthandStaticName extends ObjectPropertyBase { type: "Property"; computed: false; // non-computed, non-shorthand names are constrained significantly - key: Identifier | StringLiteral | NumericLiteral; + key: ObjectPropertyKey; value: Expression; kind: "init" | "get" | "set"; method: boolean; @@ -568,7 +585,7 @@ export interface DestructuringObjectPropertyWithNonShorthandStaticName extends D type: "Property"; computed: false; // non-computed, non-shorthand names are constrained significantly - key: Identifier | StringLiteral | NumericLiteral; + key: ObjectPropertyKey; // destructuring properties cannot have any value value: DestructuringPattern; shorthand: false; @@ -912,7 +929,7 @@ interface BaseClass extends BaseNode { body: ClassBody; typeParameters: null | TypeParameterDeclaration; - superTypeParameters: null | TypeParameterInstantiation; + superTypeArguments: null | TypeParameterInstantiation; implements: ReadonlyArray; decorators: ReadonlyArray; } @@ -923,8 +940,7 @@ export type PropertyName = export type ClassPropertyNameComputed = Expression; export type ClassPropertyNameNonComputed = | PrivateIdentifier - | Identifier - | StringLiteral; + | ObjectPropertyKey; export type ClassMember = PropertyDefinition | MethodDefinition | StaticBlock; export type ClassMemberWithNonComputedName = @@ -1085,7 +1101,8 @@ export type NamedDeclaration = | TypeAlias | OpaqueType | InterfaceDeclaration - | EnumDeclaration; + | EnumDeclaration + | RecordDeclaration; interface ExportNamedDeclarationBase extends BaseNode { type: "ExportNamedDeclaration"; @@ -1149,6 +1166,9 @@ export type TypeAnnotationType = | ThisTypeAnnotation | MixedTypeAnnotation | VoidTypeAnnotation + | UnknownTypeAnnotation + | NeverTypeAnnotation + | UndefinedTypeAnnotation | StringLiteralTypeAnnotation | NumberLiteralTypeAnnotation | BigIntLiteralTypeAnnotation @@ -1243,6 +1263,15 @@ export interface MixedTypeAnnotation extends BaseNode { export interface VoidTypeAnnotation extends BaseNode { type: "VoidTypeAnnotation"; } +export interface UnknownTypeAnnotation extends BaseNode { + type: "UnknownTypeAnnotation"; +} +export interface NeverTypeAnnotation extends BaseNode { + type: "NeverTypeAnnotation"; +} +export interface UndefinedTypeAnnotation extends BaseNode { + type: "UndefinedTypeAnnotation"; +} export interface StringLiteralTypeAnnotation extends BaseNode { type: "StringLiteralTypeAnnotation"; value: string; @@ -1301,7 +1330,7 @@ export interface KeyofTypeAnnotation extends BaseNode { } export interface TupleTypeAnnotation extends BaseNode { type: "TupleTypeAnnotation"; - types: ReadonlyArray; + elementTypes: ReadonlyArray; inexact: boolean; } export interface TupleTypeSpreadElement extends BaseNode { @@ -1448,7 +1477,7 @@ export interface ObjectTypeAnnotation extends BaseNode { } interface ObjectTypePropertyBase extends BaseNode { type: "ObjectTypeProperty"; - key: Identifier | StringLiteral; + key: ObjectPropertyKey; value: TypeAnnotationType; method: boolean; optional: boolean; @@ -2042,6 +2071,7 @@ export type MatchPattern = | MatchMemberPattern | MatchBindingPattern | MatchObjectPattern + | MatchInstancePattern | MatchArrayPattern; export interface MatchOrPattern extends BaseNode { @@ -2086,10 +2116,20 @@ export interface MatchObjectPattern extends BaseNode { } export interface MatchObjectPatternProperty extends BaseNode { type: "MatchObjectPatternProperty"; - key: Identifier | StringLiteral | NumericLiteral | BigIntLiteral; + key: ObjectPropertyKey; pattern: MatchPattern; shorthand: boolean; } +export interface MatchInstancePattern extends BaseNode { + type: "MatchInstancePattern"; + targetConstructor: MatchIdentifierPattern | MatchMemberPattern; + properties: MatchInstanceObjectPattern; +} +export interface MatchInstanceObjectPattern extends BaseNode { + type: "MatchInstanceObjectPattern"; + properties: ReadonlyArray; + rest: MatchRestPattern | null; +} export interface MatchArrayPattern extends BaseNode { type: "MatchArrayPattern"; elements: ReadonlyArray; @@ -2100,6 +2140,58 @@ export interface MatchRestPattern extends BaseNode { argument: MatchBindingPattern | null; } +/*********** + * Records * + ***********/ +export interface RecordDeclaration extends BaseNode { + type: "RecordDeclaration"; + id: Identifier; + typeParameters: TypeParameterDeclaration | null; + implements: ReadonlyArray; + body: RecordDeclarationBody; +} + +export interface RecordDeclarationImplements extends BaseNode { + type: "RecordDeclarationImplements"; + id: Identifier; + typeArguments: TypeParameterInstantiation | null; +} + +export interface RecordDeclarationBody extends BaseNode { + type: "RecordDeclarationBody"; + elements: ReadonlyArray< + | RecordDeclarationProperty + | RecordDeclarationStaticProperty + | MethodDefinition + >; +} + +export interface RecordDeclarationProperty extends BaseNode { + type: "RecordDeclarationProperty"; + key: ObjectPropertyKey; + typeAnnotation: TypeAnnotation; + defaultValue: Expression | null; +} + +export interface RecordDeclarationStaticProperty extends BaseNode { + type: "RecordDeclarationStaticProperty"; + key: ObjectPropertyKey; + typeAnnotation: TypeAnnotation; + value: Expression; +} + +export interface RecordExpression extends BaseNode { + type: "RecordExpression"; + recordConstructor: Expression; + typeArguments: TypeParameterInstantiation | null; + properties: RecordExpressionProperties; +} + +export interface RecordExpressionProperties extends BaseNode { + type: "RecordExpressionProperties"; + properties: ReadonlyArray; +} + /****************************************************** * Deprecated spec nodes awaiting migration by Hermes * ******************************************************/ diff --git a/src/language-js/types/typescript-estree.ts b/src/language-js/types/typescript-estree.d.ts similarity index 100% rename from src/language-js/types/typescript-estree.ts rename to src/language-js/types/typescript-estree.d.ts diff --git a/src/language-js/utilities/index.js b/src/language-js/utilities/index.js index 43be81ef5..69c7a3db2 100644 --- a/src/language-js/utilities/index.js +++ b/src/language-js/utilities/index.js @@ -27,6 +27,7 @@ import { isObjectExpression, isObjectType, isReturnOrThrowStatement, + isTupleType, isTypeAlias, isUnionType, } from "./node-types.js"; @@ -1119,6 +1120,7 @@ export { isTemplateOnItsOwnLine, isTestCall, isTsAsConstExpression, + isTupleType, isTypeAlias, isTypeAnnotationAFunction, isUnionType, diff --git a/src/language-js/utilities/node-types.js b/src/language-js/utilities/node-types.js index fbed65f31..045bb67b5 100644 --- a/src/language-js/utilities/node-types.js +++ b/src/language-js/utilities/node-types.js @@ -20,6 +20,11 @@ export const isIntersectionType = createTypeCheckFunction([ "IntersectionTypeAnnotation", ]); +export const isTupleType = createTypeCheckFunction([ + "TupleTypeAnnotation", + "TSTupleType", +]); + export const isConditionalType = createTypeCheckFunction([ "TSConditionalType", "ConditionalTypeAnnotation", diff --git a/src/utilities/visitor-keys.js b/src/utilities/visitor-keys.js index 4ce303eec..31b88b342 100644 --- a/src/utilities/visitor-keys.js +++ b/src/utilities/visitor-keys.js @@ -12,9 +12,7 @@ function unionVisitorKeys(...all) { /** @type {VisitorKeys} */ const result = {}; - for (const [type, keys] of all - .flatMap((keys) => Object.entries(keys)) - .sort(([keyA], [keyB]) => keyA.localeCompare(keyB))) { + for (const [type, keys] of all.flatMap((keys) => Object.entries(keys))) { result[type] = unique([...(result[type] ?? []), ...keys]); } @@ -47,6 +45,34 @@ function removeVisitorKeys(visitorKeys, keysToRemove) { return result; } +/** +@param {VisitorKeys} visitorKeys +@param {VisitorKeys} keysToAdd +@returns {VisitorKeys} +*/ +function addVisitorKeys(visitorKeys, keysToAdd) { + const result = { ...visitorKeys }; + + for (const [type, keys] of Object.entries(keysToAdd)) { + if (keys.length === 0 && Object.hasOwn(result, type)) { + throw new Error(`Node type "${type}" already exists in visitor keys.`); + } + + const existing = [...(result[type] ?? [])]; + + for (const key of keys) { + if (existing.includes(key)) { + throw new Error(`"${key}" already exists in "${type}" visitor keys.`); + } + existing.push(key); + } + + result[type] = existing; + } + + return result; +} + /** @param {VisitorKeys} visitorKeys @param {string[]} nodeTypesToRemove @@ -88,6 +114,7 @@ function generateReferenceSharedVisitorKeys(visitorKeys) { } export { + addVisitorKeys, generateReferenceSharedVisitorKeys, removeNodeTypes, removeVisitorKeys, diff --git a/tests/format/flow/tuple-types/__snapshots__/format.test.js.snap b/tests/format/flow/tuple-types/__snapshots__/format.test.js.snap index 3f477b62e..0fd945f9f 100644 --- a/tests/format/flow/tuple-types/__snapshots__/format.test.js.snap +++ b/tests/format/flow/tuple-types/__snapshots__/format.test.js.snap @@ -2,7 +2,7 @@ exports[`trailing-comma.js - {"trailingComma":"all"} format 1`] = ` ====================================options===================================== -parsers: ["flow"] +parsers: ["flow", "babel-flow"] printWidth: 80 trailingComma: "all" | printWidth diff --git a/tests/format/flow/tuple-types/format.test.js b/tests/format/flow/tuple-types/format.test.js index 41118a8fb..b70ad5458 100644 --- a/tests/format/flow/tuple-types/format.test.js +++ b/tests/format/flow/tuple-types/format.test.js @@ -1,3 +1,3 @@ runFormatTest(import.meta, ["flow"], { trailingComma: "none" }); runFormatTest(import.meta, ["flow"], { trailingComma: "es5" }); -runFormatTest(import.meta, ["flow"], { trailingComma: "all" }); +runFormatTest(import.meta, ["flow", "babel-flow"], { trailingComma: "all" }); diff --git a/tests/format/js/dynamic-import/__snapshots__/format.test.js.snap b/tests/format/js/dynamic-import/__snapshots__/format.test.js.snap index 6453f6ff9..35702f306 100644 --- a/tests/format/js/dynamic-import/__snapshots__/format.test.js.snap +++ b/tests/format/js/dynamic-import/__snapshots__/format.test.js.snap @@ -1,12 +1,5 @@ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing -exports[`assertions.js [flow] format 1`] = ` -"Unexpected token \`,\`, expected the token \`)\` (1:20) -> 1 | import("./foo.json", { assert: { type: "json" } }); - | ^ - 2 |" -`; - exports[`assertions.js format 1`] = ` ====================================options===================================== parsers: ["babel", "flow", "typescript"] diff --git a/tests/format/js/dynamic-import/format.test.js b/tests/format/js/dynamic-import/format.test.js index ced22507d..3c75120ca 100644 --- a/tests/format/js/dynamic-import/format.test.js +++ b/tests/format/js/dynamic-import/format.test.js @@ -1,6 +1,6 @@ runFormatTest(import.meta, ["babel", "flow", "typescript"], { errors: { - flow: ["assertions.js", "template-literal.js", "import-phase.js"], + flow: ["template-literal.js", "import-phase.js"], hermes: ["template-literal.js", "import-phase.js"], acorn: ["import-phase.js"], espree: ["import-phase.js"], diff --git a/tests/format/js/explicit-resource-management/__snapshots__/format.test.js.snap b/tests/format/js/explicit-resource-management/__snapshots__/format.test.js.snap index 3c29fe40a..59562b9c7 100644 --- a/tests/format/js/explicit-resource-management/__snapshots__/format.test.js.snap +++ b/tests/format/js/explicit-resource-management/__snapshots__/format.test.js.snap @@ -839,15 +839,15 @@ exports[`valid-module-block-top-level-await-using-binding.js [flow] format 1`] = `; exports[`valid-module-block-top-level-await-using-binding.js [hermes] format 1`] = ` -"';' expected (1:17) -> 1 | const m = module { - | ^ - 2 | await using foo = bar(); +"':' expected in property initialization (2:8) + 1 | const m = module { +> 2 | await using foo = bar(); + | ^ 3 | } 4 | -Cause: ';' expected (1:17) -const m = module { - ^" +Cause: ':' expected in property initialization (2:8) + await using foo = bar(); + ~~~~~~^" `; exports[`valid-module-block-top-level-await-using-binding.js [meriyah] format 1`] = ` @@ -936,15 +936,15 @@ exports[`valid-module-block-top-level-using-binding.js [flow] format 1`] = ` `; exports[`valid-module-block-top-level-using-binding.js [hermes] format 1`] = ` -"';' expected (1:7) -> 1 | module { - | ^ - 2 | using foo = bar(); +"':' expected in property initialization (2:8) + 1 | module { +> 2 | using foo = bar(); + | ^ 3 | } 4 | -Cause: ';' expected (1:7) -module { - ^" +Cause: ':' expected in property initialization (2:8) + using foo = bar(); + ~~~~~~^" `; exports[`valid-module-block-top-level-using-binding.js [meriyah] format 1`] = ` diff --git a/tests/format/misc/errors/flow/__snapshots__/format.test.js.snap b/tests/format/misc/errors/flow/__snapshots__/format.test.js.snap index e06cf2486..9c1cca9cf 100644 --- a/tests/format/misc/errors/flow/__snapshots__/format.test.js.snap +++ b/tests/format/misc/errors/flow/__snapshots__/format.test.js.snap @@ -8,13 +8,6 @@ exports[`async-arrow-invalid.js [flow] format 1`] = ` | ^" `; -exports[`dynamic-import.js [flow] format 1`] = ` -"Unexpected token \`,\`, expected the token \`)\` (1:24) -> 1 | import('./prettier.mjs', {}) - | ^ - 2 |" -`; - exports[`function-async.js [flow] format 1`] = ` "Unexpected token \`;\`, expected the token \`=>\` (2:11) 1 | // Flow can't parse this since \`v0.128.0\`, #8661 @@ -29,13 +22,6 @@ exports[`invalid_keyword_symbol.js [flow] format 1`] = ` 2 |" `; -exports[`module-attributes-dynamic.js [flow] format 1`] = ` -"Unexpected token \`,\`, expected the token \`)\` (1:18) -> 1 | import("foo.json", { with: { type: "json" } }) - | ^ - 2 |" -`; - exports[`module-attributes-static.js [flow] format 1`] = ` "Unexpected token \`with\`, expected the token \`;\` (1:28) > 1 | import foo from "foo.json" with type: "json"; diff --git a/tests/format/misc/errors/flow/dynamic-import.js b/tests/format/misc/errors/flow/dynamic-import.js deleted file mode 100644 index 2c6d4b2f3..000000000 --- a/tests/format/misc/errors/flow/dynamic-import.js +++ /dev/null @@ -1 +0,0 @@ -import('./prettier.mjs', {}) diff --git a/tests/format/misc/errors/flow/module-attributes-dynamic.js b/tests/format/misc/errors/flow/module-attributes-dynamic.js deleted file mode 100644 index baa60fc43..000000000 --- a/tests/format/misc/errors/flow/module-attributes-dynamic.js +++ /dev/null @@ -1 +0,0 @@ -import("foo.json", { with: { type: "json" } }) diff --git a/tests/unit/__snapshots__/visitor-keys.js.snap b/tests/unit/__snapshots__/visitor-keys.js.snap index 8a07e02c2..3b1e7ab40 100644 --- a/tests/unit/__snapshots__/visitor-keys.js.snap +++ b/tests/unit/__snapshots__/visitor-keys.js.snap @@ -98,7 +98,6 @@ exports[`visitor keys estree 1`] = ` "mixins", "superClass", "superTypeArguments", - "superTypeParameters", "typeParameters", ], "ClassExpression": [ @@ -109,7 +108,6 @@ exports[`visitor keys estree 1`] = ` "mixins", "superClass", "superTypeArguments", - "superTypeParameters", "typeParameters", ], "ClassImplements": [ @@ -1077,7 +1075,6 @@ exports[`visitor keys estree 1`] = ` ], "TupleTypeAnnotation": [ "elementTypes", - "types", ], "TupleTypeLabeledElement": [ "elementType", diff --git a/yarn.lock b/yarn.lock index 0afe53f5d..9d3e04b1a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4681,10 +4681,10 @@ __metadata: languageName: node linkType: hard -"flow-parser@npm:0.291.0": - version: 0.291.0 - resolution: "flow-parser@npm:0.291.0" - checksum: 10/1961b1208385263efd7b1d03db2de0f1a93dc31453bacd5a482086add64189049e820af129982b0d848084e853310945c2d70b7ba83ebb811051325f85c19ce0 +"flow-parser@npm:0.294.0": + version: 0.294.0 + resolution: "flow-parser@npm:0.294.0" + checksum: 10/ad4e01355fa5719c98a158f3aa9c9acf181f8e973d81fa38e28bf7977d9c9b3be14f14bc36d1e54896d3532b3a91d1d65aba8f8fe8dc079073697726083464ee languageName: node linkType: hard @@ -5003,19 +5003,19 @@ __metadata: languageName: node linkType: hard -"hermes-estree@npm:0.32.1": - version: 0.32.1 - resolution: "hermes-estree@npm:0.32.1" - checksum: 10/6d0c03216c69fcabe6a534ffcffd4bc21b54de1e7ae3c81f1cafce36c33c4acafe334ee27e865f65549b78971dbdb3d78be9b40281365a162c6a23a6b8f1e06b +"hermes-estree@npm:0.33.0": + version: 0.33.0 + resolution: "hermes-estree@npm:0.33.0" + checksum: 10/dff69960345cc3cf034a5f1cb92c0c87a8d5cd9e136d0840e92cfff9fe7453088b792661cbcdf0b4a087de9b1e5d208db740b5505b1d4bef9f1e2133cdf3b4cf languageName: node linkType: hard -"hermes-parser@npm:0.32.1": - version: 0.32.1 - resolution: "hermes-parser@npm:0.32.1" +"hermes-parser@npm:0.33.0": + version: 0.33.0 + resolution: "hermes-parser@npm:0.33.0" dependencies: - hermes-estree: "npm:0.32.1" - checksum: 10/f392d309e3e9d01a01fd71bda83a488906b1182ebf4073768a6528b28c7a1b54f099a4170593dcfad886c434927dbedf93eff985ec6cf78af4c6eded10e26f03 + hermes-estree: "npm:0.33.0" + checksum: 10/69da5c96459e9be53616045756be7a2b97ed40bdab66a0181fe783a68cba2fb21c2bd8e2177e8cb5369e7a120656d32d8d892b35438818b93e46dfcbfd99edee languageName: node linkType: hard @@ -7339,13 +7339,13 @@ __metadata: fast-json-stable-stringify: "npm:2.1.0" file-entry-cache: "npm:11.1.1" find-cache-directory: "npm:6.0.0" - flow-parser: "npm:0.291.0" + flow-parser: "npm:0.294.0" get-east-asian-width: "npm:1.4.0" get-stdin: "npm:9.0.0" gfm-test-suite: "npm:0.0.2" globals: "npm:16.5.0" graphql: "npm:16.12.0" - hermes-parser: "npm:0.32.1" + hermes-parser: "npm:0.33.0" html-element-attributes: "npm:3.5.0" html-ua-styles: "npm:0.2.0" ignore: "npm:7.0.5"