Skip to content

fix: Improve TypeScript support #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

micksatana
Copy link

Hi @santigimeno,

Thanks for this great lib! I'm using it to develop on one of my project. I've come across some issue with TypeScript when I want to organize handler functions without nesting them too much. Like the following..

import PCSCLite, { CardReader } from 'pcsclite';

const pcsc = PCSCLite();

const onReaderError = (e: Error) => {
    console.log(e.message);
};

const onReaderDetected = (reader: CardReader) => {
    // Listen to all other reader events here; for example,
    reader.on('error', onReaderError);
};

pcsc.on('reader', onReaderDetected);

The problem with the current code will be the CardReader as it's not exported and the types is not specified in package.json. This causes the onReaderDetected above having type issue.

I've made some adjustment to make this work. Please consider my PR, if it's ok to merge.

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