From 8b26129d55e8a3ebcc790341ad3db6a905731be1 Mon Sep 17 00:00:00 2001 From: David Anson Date: Tue, 10 Dec 2024 21:47:06 -0800 Subject: [PATCH] Convert types.d.mts from ambient module declaration to module augmentation which enables VS Code to handle `@type {import("markdownlint").Rule}` (https://www.typescriptlang.org/docs/handbook/modules/reference.html#ambient-modules), fix broken markdownlint @typedefs in helpers/*.cjs. --- helpers/helpers.cjs | 6 +++--- helpers/micromark-helpers.cjs | 2 +- lib/types.d.mts | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/helpers/helpers.cjs b/helpers/helpers.cjs index 5b5f6491f..6b42f0ab6 100644 --- a/helpers/helpers.cjs +++ b/helpers/helpers.cjs @@ -10,11 +10,11 @@ module.exports.newLineRe = newLineRe; module.exports.nextLinesRe = nextLinesRe; // @ts-expect-error https://github.com/microsoft/TypeScript/issues/52529 -/** @typedef {import("markdownlint").RuleOnError} RuleOnError */ +/** @typedef {import("../lib/exports.mjs").RuleOnError} RuleOnError */ // @ts-expect-error https://github.com/microsoft/TypeScript/issues/52529 -/** @typedef {import("markdownlint").RuleOnErrorFixInfo} RuleOnErrorFixInfo */ +/** @typedef {import("../lib/exports.mjs").RuleOnErrorFixInfo} RuleOnErrorFixInfo */ // @ts-expect-error https://github.com/microsoft/TypeScript/issues/52529 -/** @typedef {import("markdownlint").MicromarkToken} MicromarkToken */ +/** @typedef {import("../lib/exports.mjs").MicromarkToken} MicromarkToken */ // eslint-disable-next-line jsdoc/valid-types /** @typedef {import("micromark-extension-gfm-footnote", { with: { "resolution-mode": "import" } })} */ // eslint-disable-next-line jsdoc/valid-types diff --git a/helpers/micromark-helpers.cjs b/helpers/micromark-helpers.cjs index bed42c862..842c8210a 100644 --- a/helpers/micromark-helpers.cjs +++ b/helpers/micromark-helpers.cjs @@ -7,7 +7,7 @@ const { flatTokensSymbol, htmlFlowSymbol } = require("./shared.cjs"); // eslint-disable-next-line jsdoc/valid-types /** @typedef {import("micromark-util-types", { with: { "resolution-mode": "import" } }).TokenType} TokenType */ // @ts-expect-error https://github.com/microsoft/TypeScript/issues/52529 -/** @typedef {import("markdownlint").MicromarkToken} Token */ +/** @typedef {import("../lib/exports.mjs").MicromarkToken} Token */ /** * Determines if a Micromark token is within an htmlFlow type. diff --git a/lib/types.d.mts b/lib/types.d.mts index 2ca3e4d35..462a7d271 100644 --- a/lib/types.d.mts +++ b/lib/types.d.mts @@ -1,3 +1,4 @@ +export {}; declare module "markdownlint" { export * from "./exports.mjs"; }