Skip to content

feat: add Typescript typings #22

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

Merged
merged 1 commit into from
Jun 30, 2021

Conversation

IlyaSemenov
Copy link
Contributor

@IlyaSemenov IlyaSemenov commented Jun 25, 2021

Currently, importing postgres-date in a Typescript project leads to error:

Could not find a declaration file for module 'postgres-date'. '/Users/semenov/work/xxx/node_modules/postgres-date/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/postgres-date` if it exists or add a new declaration (.d.ts) file containing `declare module 'postgres-date';`ts(7016)

This PR adds typings for the exported function.

Note that Inifinity / -Infinity can not be used as number literal types yet (see microsoft/TypeScript#32277) that's why I mark the return type as Date | number.

Copy link
Owner

@bendrucker bendrucker left a comment

Choose a reason for hiding this comment

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

Please add some tests using https://github.com/SamVerschueren/tsd to verify that these are valid then I'm happy to get this merged

@IlyaSemenov
Copy link
Contributor Author

@bendrucker I added tsd tests.

@IlyaSemenov IlyaSemenov requested a review from bendrucker June 30, 2021 08:48
@bendrucker bendrucker merged commit ce3722f into bendrucker:master Jun 30, 2021
@bendrucker
Copy link
Owner

Perfect, thanks!

@IlyaSemenov IlyaSemenov deleted the feat/typescript branch July 1, 2021 06:52
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.

2 participants