Skip to content

Conversation

@Allen-Bayern
Copy link

This PR enhances TypeScript support with the following improvements:

🔧 Core Changes

  1. Added complete TypeScript type definitions (index.d.ts) with:
  • Strict event type constraints via generics
  • Proper CommonJS export declarations (export =)
  • Declaration merging for TinyEmitter static property
  1. Fixed module export alignment with original implementation:
// Now supports both usage patterns:
const Emitter = require('tiny-emitter');
new Emitter(); 

import { TinyEmitter } from 'tiny-emitter';
new TinyEmitter();
  1. Added comprehensive TypeScript documentation in README
  2. Verified type safety with TS 4.9+ strict mode

✅ Validation

  • Added type tests in test/types.test.ts
  • Verified working with:
npm version patch && npm publish

📦 Release Request

Would you please consider:

  1. Merging this PR
  2. Publishing a new minor/patch version to NPM
npm version patch && npm publish

This will significantly improve the experience for TypeScript users while maintaining full backward compatibility.

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.

1 participant