-
Notifications
You must be signed in to change notification settings - Fork 750
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
Re-introduce Typescript changes #1551
Conversation
cec1ab3
to
b523144
Compare
Co-authored-by: pakrym-stripe <99349468+pakrym-stripe@users.noreply.github.com>
7a993ff
to
3d63ada
Compare
…to import = require for migrated files
7d78602
to
c9cd4b5
Compare
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.
Few comments but this looks promising!
1fd23d4
to
6eb107f
Compare
6eb107f
to
15ccbca
Compare
LGTM. Let's talk with @xavdid-stripe tomorrow. |
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 gave the following files a fairly thorough read:
- StripeMethod
- StripeResource
- autoPagination.js
- makeRequest.js
- stripe.js
- Error.js
I spot checked a few more, but stopped when they mostly had whitespace lines removed.
Nothing jumped out as being functionally different in those files - most changes were formatting-only (or explicitly commented on as a change).
If you're looking for a more thorough comparison, one option for surfacing any non-superficial changes would be to take src/x.js
and lib/x.js
either:
- run them both through a formatter like
prettier
and then diff that result - diff the ASTs of each, so we can better compare structural changes vs formatting ones
Happy to run with that a bit if it's something you're interested in! Or we can probably call this "good enough" 😁
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 know this is merged, but wanted to quickly comment on the changes that popped out. Thanks for running prettier, really helped find changes!
_errorHandler(req, requestRetries, callback) { | ||
return (message, detail) => { | ||
callback.call( | ||
this, | ||
new StripeConnectionError({ | ||
message: this._generateConnectionErrorMessage(requestRetries), | ||
detail: error, |
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 like this line changed. Was that intentional?
const makeRequest = (apiVersion, headers, numRetries) => { | ||
// timeout can be set on a per-request basis. Favor that over the global setting | ||
const timeout = | ||
options.settings && | ||
options.settings.timeout && |
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 TS being extra defensive, no problem there.
@@ -598,11 +518,9 @@ StripeResource.prototype = { | |||
options.headers, | |||
options.settings | |||
); | |||
|
|||
makeRequest(apiVersion, headers); | |||
makeRequest(apiVersion, headers, 0); |
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 0 is an addition- I remember a comment from a previous revision, but it seems to have been wiped from GH.
@@ -150,12 +133,10 @@ const utils = (module.exports = { | |||
if (typeof arg === 'string') { | |||
opts.auth = args.pop(); | |||
} else if (utils.isOptionsHash(arg)) { | |||
const params = {...args.pop()}; | |||
|
|||
const params = Object.assign({}, args.pop()); |
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 functionally equivalent
// Expose StripeResource on the instance too | ||
this.StripeResource = Stripe.StripeResource; | ||
} | ||
|
||
Stripe.errors = require('./Error'); | ||
Stripe.errors = _Error; |
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.
These are just repoints, also fine
Summary
r? @kamil-stripe
Re-introduce the changes reverted in #1547 , with additional changes to minimize differences between the original and TypeScript-compiled JavaScript code.
The first 3 commits of this PR are separated as follows:
Object.defineProperty(exports, "__esModule", { value: true });
The remaining commits add test projects importing
stripe
with both CommonJS- and ES-style imports, and also updates imports / exports to follow this pattern:module.exports
toexport =
syntax in migrated TS files, export for instripe.ts
to preserve named and default exports.const = require
toimport = require
syntax for modules that have been migrated to TypeScript to get type checking