Skip to content
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

TypeScript updates and fixes #648

Merged
merged 4 commits into from
Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/dt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Add DefinitelyTyped header
run: |
version=$(cat recurly-js/package.json | jq '.version' -r | sed -ne 's/^\([0-9]*\.[0-9]*\).*/\1/p')
echo "// Type definitions for non-npm package recurly__recurly-js $version
echo "// Type definitions for non-npm package @recurly/recurly-js $version
// Project: https://github.com/recurly/recurly-js
// Definitions by: Dave Brudner <https://github.com/dbrudner>
// Chris Rogers <https://github.com/chrissrogers>
Expand Down
2 changes: 1 addition & 1 deletion test/types/bank-account.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TokenHandler, BacsBillingInfo, BecsBillingInfo } from 'recurly__recurly-js';
import { TokenHandler, BacsBillingInfo, BecsBillingInfo } from '@recurly/recurly-js';

export default function bankAccount() {
const handleToken: TokenHandler = (err, token) => {
Expand Down
47 changes: 47 additions & 0 deletions test/types/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,53 @@ export default function configure() {
timeout: 60000
});

const elementOptions = {
selector: 'my-selector',
format: true,
inputType: 'text',
tabIndex: '1',
style: {
invalid: {
fontSize: '16px'
},
padding: '10px',
placeholder: {
color: 'red',
content: 'content'
}
}
};

window.recurly.configure({
publicKey: 'my-public-key',
fields: {
all: elementOptions,
number: elementOptions,
month: elementOptions,
year: elementOptions,
cvv: elementOptions,
card: {
selector: 'my-card-element-selector',
inputType: 'mobileSelect',
displayIcon: true,
style: {
fontSize: '1em',
placeholder: {
color: 'gray !important',
fontWeight: 'bold',
content: {
number: 'Card number',
cvv: 'CVC'
}
},
invalid: {
fontColor: 'red'
}
}
}
}
});

// $ExpectError
window.recurly.configure({
cors: true,
Expand Down
2 changes: 2 additions & 0 deletions test/types/paypal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export default function paypal() {

paypal.on('token', () => {});
paypal.on('error', () => {});
paypal.on('cancel', () => {});
paypal.on('ready', () => {});
// $ExpectError
paypal.on('fake-event', () => {});

Expand Down
2 changes: 1 addition & 1 deletion test/types/recurly-error.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RecurlyError } from 'recurly__recurly-js';
import { RecurlyError } from '@recurly/recurly-js';

const recurlyError: RecurlyError = {
code: 'code',
Expand Down
2 changes: 1 addition & 1 deletion test/types/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"types": [],
"baseUrl": "../../types",
"paths": {
"recurly__recurly-js": ["./"]
"@recurly/recurly-js": ["./"]
}
}
}
14 changes: 14 additions & 0 deletions types/lib/configure.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { CardElementOptions, IndividualElementOptions } from './elements';

export type RecurlyOptions = {
cors?: boolean;
publicKey: string;
Expand All @@ -15,6 +17,18 @@ export type RecurlyOptions = {
sessionId?: string;
};
};

/**
* @deprecated Use {@link https://developers.recurly.com/reference/recurly-js/index.html#elements|Elements} instead.
Copy link
Member

Choose a reason for hiding this comment

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

👏

*/
fields?: {
all?: IndividualElementOptions;
number?: IndividualElementOptions & { selector?: string };
month?: IndividualElementOptions & { selector?: string };
year?: IndividualElementOptions & { selector?: string };
cvv?: IndividualElementOptions & { selector?: string };
card?: CardElementOptions & { selector?: string }
};
};

export type Configure = (recurlyConfig: RecurlyOptions | string) => void;
2 changes: 1 addition & 1 deletion types/lib/elements.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export type IndividualElementOptions = {
*
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#styling-the-individual-card-elements|Styling the invididual card elements}
*/
invalid: CommonElementStyle;
invalid?: CommonElementStyle;

/**
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/padding}
Expand Down
2 changes: 1 addition & 1 deletion types/lib/paypal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type DirectConfig = {

export type PayPalConfig = BraintreeConfig | DirectConfig;

export type PayPalEvent = 'error' | 'token';
export type PayPalEvent = 'error' | 'token' | 'cancel' | 'ready';

export type PayPalStartOptions = {
options: {
Expand Down