-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add initial Typescript support #102
Conversation
|
||
static _prepareGraphQLBase64 (data, options = {}) { | ||
const { filename, mimetype } = options | ||
if (!filename) { | ||
throw new Error('options.filename must be provided for Base64 upload') | ||
} | ||
if (!mimetype) { | ||
throw new Error('options.mimetype must be provided for Base64 upload') | ||
} | ||
|
||
if (options.bufferize) { | ||
const buffer = Buffer.from(data, 'base64') | ||
return this._prepareGraphQLBuffer(buffer, options) | ||
} | ||
|
||
return { | ||
data, | ||
filename, | ||
mimetype, | ||
} | ||
} |
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.
Got an error inside this method but it seems like we don't use it anymore?
I'm not 100% following what the goal is here? Is it to write the source code in Typescript and then boil it down to JS? That's what I would think the goal is, right? If that's the case, then there are a few things to fix here:
I can walk you through all this and whatever else I know about Typescript and Node / NPM packages...ping me! |
This PR isn't for converting the code base to have typescript support, but to have initial typescript
Yeah probably needed to pay attention to that part of the config. Switching to:
Yes this is on purpose. From the typescript docs, EDIT: Changed it to a more obvious |
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.
Looks good to me! The last thing would be to make sure it can be consumed by a toy typescript project
src/index.js
Outdated
@@ -1,5 +1,6 @@ | |||
const fs = require('fs') | |||
|
|||
const { ReadStream } = require('fs') |
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.
was this being used before without import?
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.
Oops. That snuck in while I was updating something. Removing.
types/src/index.d.ts
Outdated
rateLimiterPromiseResolver: (value: any) => void; | ||
_setRateLimiter({ tokens, intervalMs }: { | ||
tokens: any; | ||
intervalMs: any; |
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.
Any easy way to inject types for simple things like this? i.e. this should be an int
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.
Yeah looks like it should generate properly with JSDoc comments. Will add that.
types/src/index.d.ts
Outdated
responseQuery: any; | ||
mutation: any; |
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.
strings here
@@ -3,6 +3,7 @@ | |||
"version": "2.9.4", | |||
"description": "Anvil API Client", | |||
"main": "src/index.js", | |||
"types": "./types/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.
👍
seems like a fair amount of JSDoc'ing could be added to make this really worth it? |
Description of the change
Adds
tsconfig.json
andtypescript
along with some updates due totsc
compiler errors.Type of change
Related issues
Fixes
Checklists
Development
Code review