← Back to Pull requests

fix: add types for the require entry under node16/nodenext #951

Open
unknown opened this pull request with 212 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 24, 2026 20:12 UTC
Author

Fixes #941.

Problem

exports["."].require resolves to ./lib/index.cjs, but no lib/index.d.cts is published. Since TypeScript ignores the top-level "types" field when an exports map is present, a CommonJS consumer under --module nodenext/node16 gets TS7016 (Could not find a declaration file ... 'lib/index.cjs' implicitly has an 'any' type), while import consumers resolve src/index.d.ts fine.

Fix

Mirrors the layout already used in the sibling package marked-custom-heading-id:

  • rollup.config.js: the cjs build now copies src/index.d.ts to lib/index.d.cts via rollup-plugin-copy. All exports are named (no default export), so the declaration file transfers verbatim; no export default -> export = transform is needed.

  • package.json: per-condition types in the exports map (import -> ./src/index.d.ts, require -> ./lib/index.d.cts) and top-level types -> ./lib/index.d.cts.

  • test:types now runs npm run build && tsd && attw -P so every resolution mode is covered in CI.

  • lib/index.d.cts is committed, matching the repo's convention of tracking lib/index.cjs and lib/index.umd.js.
  • Verification

  • attw -P before the change: node16 (from CJS) -> "No types"; all other modes green. After: "No problems found" across node10, node16 from CJS, node16 from ESM, and bundler.

  • The issue's repro (.cts file with import { gfmHeadingId } from 'marked-gfm-heading-id' and import m = require('marked-gfm-heading-id')) compiles cleanly under tsc --strict --module nodenext --moduleResolution nodenext on TypeScript 5.9.3 and 7.0.2.

  • npm test: 7 tests, 11 snapshots pass. tsd type tests pass. npm run lint: clean.
  • Diff: 212 lines (+159 / -53) across 2 files Reviewer: UziTech Review duration: 9351m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.37) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 212 lines diff across 2 files
    0.37
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.321
    Real PR Conversation Timeline
    1 comments
    "Review active on #951"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 36.5% (MEDIUM) · Higher = larger blast radius
    36.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.5% · Safe to merge
    19.5%