Skip to content

fix: add typesVersions for subpath type resolution#9

Merged
Royal-lobster merged 1 commit intomainfrom
fix/types-versions
Apr 6, 2026
Merged

fix: add typesVersions for subpath type resolution#9
Royal-lobster merged 1 commit intomainfrom
fix/types-versions

Conversation

@Royal-lobster
Copy link
Copy Markdown
Member

@Royal-lobster Royal-lobster commented Apr 6, 2026

Summary

  • Add typesVersions field to package.json for nestjs and nextjs subpath exports
  • TypeScript with moduleResolution: "node" ignores exports maps for type resolution — typesVersions provides the fallback

Follows up on #8 (CJS support). The CJS build fixed runtime resolution but TypeScript still couldn't find types for @iqai/alert-logger/nestjs without manual tsconfig paths.

Test plan

  • Existing tests pass
  • Verified TypeScript resolves @iqai/alert-logger/nestjs types without tsconfig paths workaround

🤖 Generated with Claude Code

Closes #15

The CJS build alone isn't sufficient — TypeScript with
moduleResolution: "node" ignores exports maps entirely for type
resolution. typesVersions provides the fallback mapping for subpath
imports like @iqai/alert-logger/nestjs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Royal-lobster Royal-lobster merged commit c578183 into main Apr 6, 2026
3 checks passed
@github-actions github-actions Bot mentioned this pull request Apr 6, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces typesVersions to the package.json to support subpath type resolution for NestJS and NextJS integrations, along with a corresponding changeset. A review comment suggests adding a catch-all wildcard mapping within the typesVersions block to ensure that the root entry point's types remain resolvable, as the current configuration might cause TypeScript to ignore the top-level types field.

Comment thread package.json
Comment on lines +47 to +52
"typesVersions": {
"*": {
"nestjs": ["./dist/integrations/nestjs/index.d.ts"],
"nextjs": ["./dist/integrations/nextjs/index.d.ts"]
}
},
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When using typesVersions for subpath mapping with a wildcard version range (*), TypeScript may ignore the top-level types field for the root entry point if it doesn't find a match within the mapping. To ensure the root types remain resolvable for all users, it is a best practice to include a catch-all mapping or an explicit entry for the root.

Consider adding a wildcard mapping to the end of the block:

  "typesVersions": {
    "*": {
      "nestjs": ["./dist/integrations/nestjs/index.d.ts"],
      "nextjs": ["./dist/integrations/nextjs/index.d.ts"],
      "*": ["./dist/index.d.ts"]
    }
  },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build out @iqai/alert-logger — health policy, CJS compat, description field, fingerprint dedup

1 participant