Registry / type-stubs / micromark-util-types

micromark-util-types

JSON →
library2.0.2jsnpmunverified

micromark-util-types is a utility package within the micromark ecosystem, currently at version 2.0.2. Its sole purpose is to provide a comprehensive set of TypeScript types that are shared across various micromark packages, enabling developers to create robust and type-safe micromark extensions. The package itself exports no runtime code or identifiers, serving purely as a type declaration module. This focused approach differentiates it from general-purpose utility libraries, making it an essential dependency for anyone building custom parsers or extensions with TypeScript for micromark. Releases typically align with the broader micromark monorepo, with updates often focusing on performance, bug fixes, and maintaining compatibility with supported Node.js versions and the latest micromark parser core.

npm install micromark-util-types
INSTALL
IMPORT
SIG · MICROMARK-UTIL-TYP
M
micromark-util-types
type-stubsjavascriptv2.0.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Point
import type { Point } from 'micromark-util-types'
import { Point } from 'micromark-util-types'
This package exports only TypeScript types; `import type` is essential. Attempting to import values will result in a runtime error or compilation failure.
State
import type { State } from 'micromark-util-types'
const { State } = require('micromark-util-types')
As an ESM-only package focused on types, CommonJS `require()` is not supported for importing these declarations.
TokenType
import type { TokenType } from 'micromark-util-types'
import TokenType from 'micromark-util-types'
There are no default exports. All types are named exports and must be imported explicitly using `import type { ... } from '...'`.

Demonstrates importing and utilizing key TypeScript types like `Code`, `State`, `Effects`, `TokenType`, `Point`, and `Token` to define functions for a custom micromark tokenizer extension.

import type { Code, State, Effects, TokenType, Point, Token } from 'micromark-util-types'; // Example: A simple state function for a custom micromark extension function factory(effects: Effects, ok: State, nok: State): State { return start; function start(code: Code): State | undefined { // Implement custom parsing logic here if (code === 91 /* `[` */) { effects.enter('myCustomNode' as TokenType); effects.consume(code); return afterOpenBracket; } return nok(code); } function afterOpenBracket(code: Code): State | undefined { if (code === 93 /* `]` */) { effects.exit('myCustomNode' as TokenType); effects.consume(code); return ok; } return nok(code); } } // This code snippet demonstrates how to leverage types from micromark-util-types // within a custom micromark extension. The 'factory' function would be integrated // into a micromark tokenizer. This file compiles but does not have a runtime effect // as it's purely for type demonstration. console.log('Micromark types loaded for extension development.');
Debug
Known issues
breakingThe `micromark-util-types@2` package is explicitly stated to be compatible with `micromark@3` and Node.js 16+. While the overall micromark monorepo is at version `4.x`, using `micromark-util-types@2` with `micromark@4` (or newer) might lead to type mismatches or runtime issues if API types have diverged. Always check for corresponding major versions of utility packages when updating the main `micromark` parser.
fix
Consult the `micromark` monorepo changelog or relevant package `README` for version compatibility. Upgrade `micromark-util-types` to a major version explicitly supporting your `micromark` core version, if available.
affects: >=2.0.0 (when used with micromark@4.0.0+)
gotchaThis package exports *only* TypeScript types and no runtime JavaScript code. Attempting to import any symbol without the `type` keyword (e.g., `import { Point } from '...'`) will lead to compilation errors in TypeScript or runtime errors if type-checking is bypassed, as there are no actual values to import.
fix
Always use `import type { SymbolName } from 'micromark-util-types'` to correctly import type definitions.
affects: >=1.0.0
breakingAs part of the unified collective, `micromark-util-types` adheres to Node.js LTS version compatibility. Major releases of micromark packages often drop support for unmaintained Node.js versions. `micromark-util-types@2` specifically targets Node.js 16+. Using it with older Node.js environments is not supported and may lead to unexpected behavior or crashes.
fix
Ensure your Node.js environment meets the minimum requirement (currently Node.js 16+ for `micromark-util-types@2`). Upgrade Node.js if necessary.
affects: <2.0.0 (or newer majors with older Node.js)
gotchaThe package is ESM-only. Direct `require()` statements in CommonJS modules will fail at runtime. Even with transpilation, the expectation is for `import` statements and an ESM context for proper operation.
fix
Use `import type` statements within an ESM context or a build setup that transpiles to ESM. If stuck in CommonJS, consider dynamic `import()` or review your project's module strategy.
affects: >=1.0.0
Errors
Common errors & fixes
Module 'micromark-util-types' has no exported member 'someValue'. Did you mean to use 'import type'?
Attempting to import a non-type value or a type without the `type` keyword from `micromark-util-types`, which only exports TypeScript types.
fix
Change your import statement to `import type { someValue } from 'micromark-util-types'`.
Cannot find module 'micromark-util-types' or its corresponding type declarations.
The package is not installed, or TypeScript is misconfigured and cannot locate the type declarations (e.g., `moduleResolution` settings, incorrect `baseUrl`, or an outdated `tsconfig.json`).
fix
Ensure the package is installed: `npm install micromark-util-types`. Verify your `tsconfig.json` has appropriate `moduleResolution` (e.g., `node16` or `bundler`) and `typeRoots` settings. For older TypeScript versions, ensure compatibility with micromark's types.
TypeError: micromark_util_types_1.Point is not a constructor
This error occurs at runtime when a symbol imported from `micromark-util-types` is treated as a JavaScript value (e.g., a class or function) rather than a TypeScript type. This package provides no runtime code.
fix
Review the code where `Point` (or other types from this package) is used. It should only appear in type annotations or declarations, never as a value in runnable JavaScript code. Ensure `import type` is used.
Upgrade
Version history
2.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
31 hits · last 30 days
node
28
OpenAI (training)
2
Resources
micromark-util-types — npm install micromark-util-types · libregistry