Semi-manually create TypeScript declarations for all exported types from markdownlint-micromark (directions in types.d.ts).

This commit is contained in:
David Anson 2024-03-04 21:01:56 -08:00
parent 2b73095ebd
commit 3f31d6f7a2
4 changed files with 1831 additions and 2 deletions

View file

@ -0,0 +1,40 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"projectFolder": ".",
"mainEntryPointFilePath": "<projectFolder>/types.d.ts",
"bundledPackages": [ "*" ],
"newlineKind": "os",
"compiler": {
"overrideTsconfig": {}
},
"apiReport": {
"enabled": false
},
"docModel": {
"enabled": false
},
"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "<projectFolder>/micromark.d.ts"
},
"tsdocMetadata": {
"enabled": false
},
"messages": {
"compilerMessageReporting": {
"default": {
"logLevel": "warning"
}
},
"extractorMessageReporting": {
"default": {
"logLevel": "warning"
}
},
"tsdocMessageReporting": {
"default": {
"logLevel": "warning"
}
}
}
}

1751
micromark/micromark.d.ts vendored Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,9 +1,10 @@
{
"name": "markdownlint-micromark",
"version": "0.1.8",
"version": "0.1.9",
"description": "A trivial package that re-exports some micromark functionality as a CommonJS module",
"type": "commonjs",
"exports": "./micromark.cjs",
"types": "./micromark.d.ts",
"author": "David Anson (https://dlaa.me/)",
"license": "MIT",
"homepage": "https://github.com/DavidAnson/markdownlint",
@ -14,18 +15,30 @@
"bugs": "https://github.com/DavidAnson/markdownlint/issues",
"funding": "https://github.com/sponsors/DavidAnson",
"scripts": {
"build": "webpack --stats minimal"
"build": "webpack --stats minimal",
"types": "api-extractor run --local"
},
"engines": {
"node": ">=18"
},
"files": [
"LICENSE",
"micromark-browser.js",
"micromark-html-browser.js",
"micromark.cjs",
"micromark.d.ts",
"package.json",
"README.md"
],
"devDependencies": {
"@microsoft/api-extractor": "7.42.3",
"micromark": "4.0.0",
"micromark-extension-directive": "3.0.0",
"micromark-extension-gfm-autolink-literal": "2.0.0",
"micromark-extension-gfm-footnote": "2.0.0",
"micromark-extension-gfm-table": "2.0.0",
"micromark-extension-math": "3.0.0",
"micromark-util-types": "2.0.0",
"terser-webpack-plugin": "5.3.10",
"webpack": "5.90.3",
"webpack-cli": "5.1.4"

25
micromark/types.d.ts vendored Normal file
View file

@ -0,0 +1,25 @@
// Manually update due to api-extractor limitations including:
// - https://github.com/microsoft/rushstack/issues/1709
// - ERROR: Failed to fetch entity for import() type node: import('micromark-util-types').ParseContext
// - Unwillingness to treat "katex" as one of bundledPackages
//
// 1. npm install
// 2. Comment-out micromark-util-types/ParseContext in node_modules/micromark-extension-gfm-footnote/index.d.ts
// 3. npm run types
// 4. Remove "import { KatexOptions as KatexOptions_2 } from 'katex';"
// 5. Replace "KatexOptions_2" with "Object"
// 6. Append "declare module 'micromark-util-types' { interface TokenTypeMap { ... } }" from:
// - node_modules/micromark-extension-directive/index.d.ts
// - node_modules/micromark-extension-gfm-autolink-literal/index.d.ts
// - node_modules/micromark-extension-gfm-footnote/index.d.ts
// - node_modules/micromark-extension-gfm-table/index.d.ts
// - node_modules/micromark-extension-math/index.d.ts
export type { directive, directiveHtml } from "micromark-extension-directive";
export type { gfmAutolinkLiteral, gfmAutolinkLiteralHtml } from "micromark-extension-gfm-autolink-literal";
export type { gfmFootnote, gfmFootnoteHtml } from "micromark-extension-gfm-footnote";
export type { gfmTable, gfmTableHtml } from "micromark-extension-gfm-table";
export type { math, mathHtml } from "micromark-extension-math";
export type { compile, parse, postprocess, preprocess } from "micromark";
export type { CompileData, Event, ParseOptions, Token, TokenType, TokenTypeMap } from "micromark-util-types";