-
-
Notifications
You must be signed in to change notification settings - Fork 34
Add TypeScript typings #63
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
Conversation
Thanks! Can you also add tsd tests? |
@kibertoad I tried to write tsd tests, but tsd crashes with named tuples introduced in typescript 4.0. Named tuples are used to describe the Node-style callback function. Do you know any other ways to describe callbacks like this? cb(error: null, result: SomeResult);
cb(error: SomeError, result: undefined); |
@evgenymarkov Isn't named tuple an overkill here? Why not just do
|
"compilerOptions": { | ||
/* Basic Options */ | ||
"noEmit": true, | ||
"lib": ["ES2020"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this version specifically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It just example. I downgraded target settings in 4851fbd.
index.d.ts
Outdated
transact: typeof transact; | ||
}; | ||
|
||
type Options = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why aren't Options exported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in f2a868e.
tools/build-examples.sh
Outdated
|
||
set -ex | ||
|
||
npx tsc --project ./examples/typescript/single-db/tsconfig.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not cross-platform. why not make it an npm script instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 9e1ca07
tsconfig.json
Outdated
@@ -0,0 +1,14 @@ | |||
{ | |||
"include": ["./index.d.ts"], | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest following fastify config: https://github.com/fastify/fastify/blob/master/types/tsconfig.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kibertoad Thank you for review! I will respond or fix the comments asap. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@darkgl0w Hi, do you want to review pull request? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Great work!
It should be released as v3.0.2, the current version does not have |
* Types: Add "pg" property to FastifyInstance As recommended in the guide for creating TypeScript compatible Fastify plugins, properties that the Fastify instances are decorated with should also in the types get added to those instances: https://www.fastify.io/docs/latest/TypeScript/#creating-a-typescript-fastify-plugin This change follows up on #63 by adding that. * Document "name" option * Enable use of non-docker postgres db in tests * Fix tests when no error is thrown * Throw if named and unnamed are combined * Clarify that intention is to manually add type
Hello! I tried to use this plugin in my project written in TypeScript and it didn't work due to lack of typings. Please check my changes. I can polish them if there are any comments.
Caveats:
Transact helper seems overcomplicated. I couldn't write the types for this case:
Also, this is very dangerous code, because if you forget to add
catch()
to the transaction, you will get an unhandled promise rejection error.Checklist
npm run test
andnpm run benchmark
and the Code of conduct
Videos from VSCode: database, transaction.