importAssertions = Parser =>
	class extends Parser {
		/**
		 * @this {InstanceType<AcornParser>}
		 * @returns {ImportAttribute[]} import attributes
		 */
		parseWithClause() {
			/** @type {ImportAttribute[]} */
			const nodes = [];

			const isAssertLegacy = this.value === "assert";

			if (isAssertLegacy) {
				if (!this.eat(tokTypes.name)) {
					return nodes;
				}
			} else if (!this.eat(tokTypes._with)) {
				return nodes;
			}

			this.expect(tokTypes.braceL);

			/** @type {Record<string, boolean>} */
			const attributeKeys = {};
			let first = true;

			while (!this.eat(tokTypes.braceR)) {
				if (!first) {
					this.expect(tokTypes.comma);
					if (this.afterTrailingComma(tokTypes.braceR)) {
						break;
					}
				} else {
					first = false;
				}

				const attr =
					/** @type {ImportAttribute} */
					this.parseImportAttribute();
				const keyName =
					attr.key.type === "Identifier" ? attr.key.name : attr.key.value;

				if (Object.prototype.hasOwnProperty.call(attributeKeys, keyName)) {
					this.raiseRecoverable(
						attr.key.start,
						`Duplicate attribute key '${keyName}'`
					);
				}

				attributeKeys[keyName] = true;
				nodes.push(attr);
			}

			if (isAssertLegacy) {
				/** @type {EXPECTED_ANY} */
				(nodes)[LEGACY_ASSERT_ATTRIBUTES] = true;
			}

			return nodes;
		}
	}
@type {(BaseParser: typeof AcornParser) => typeof AcornParser}