diff --git a/types/braintree-web/american-express.d.ts b/types/braintree-web/american-express.d.ts index bf52541a8b8350..bdb67bef1eec91 100644 --- a/types/braintree-web/american-express.d.ts +++ b/types/braintree-web/american-express.d.ts @@ -42,5 +42,14 @@ export interface AmericanExpress { getExpressCheckoutProfile(options: { nonce: string }, callback: callback): void; } -export function create(options: { client: Client }): Promise; -export function create(options: { client: Client }, callback: callback): void; +export function create(options: { + client?: Client | undefined; + authorization?: string | undefined; +}): Promise; +export function create( + options: { + client?: Client | undefined; + authorization?: string | undefined; + }, + callback: callback, +): void; diff --git a/types/braintree-web/apple-pay.d.ts b/types/braintree-web/apple-pay.d.ts index d5a659cd5aee90..265ecf5658ca1b 100644 --- a/types/braintree-web/apple-pay.d.ts +++ b/types/braintree-web/apple-pay.d.ts @@ -305,10 +305,15 @@ export class ApplePaySession { static readonly STATUS_PIN_REQUIRED: number; } +export type ApplePayPaymentRequestResult = ApplePayPaymentRequest | Promise; + +export type ApplePay = ApplePayBase; +export type ApplePayDeferred = ApplePayBase>; + /** * @description Accept Apple Pay on the Web. *This component is currently in beta and is subject to change.* */ -export interface ApplePay { +export interface ApplePayBase { /** * @description A special merchant ID which represents the merchant association with Braintree. Required when using ApplePaySession.canMakePaymentsWithActiveCard. */ @@ -347,7 +352,7 @@ export interface ApplePay { "countryCode" | "currencyCode" | "merchantCapabilities" | "supportedNetworks" > >, - ): ApplePayPaymentRequest; + ): T; /** * Validates the merchant website, as required by ApplePaySession before payment can be authorized. * - The canonical name for your store. @@ -430,5 +435,32 @@ export interface ApplePay { teardown(): Promise; } -export function create(options: { client: Client }): Promise; -export function create(options: { client: Client }, callback?: callback): void; +export function create(options: { + client?: Client | undefined; + authorization?: string | undefined; + useDeferredClient?: false | undefined; +}): Promise; + +export function create(options: { + client?: Client | undefined; + authorization?: string | undefined; + useDeferredClient: true; +}): Promise; + +export function create( + options: { + client?: Client | undefined; + authorization?: string | undefined; + useDeferredClient?: false | undefined; + }, + callback: callback, +): void; + +export function create( + options: { + client?: Client | undefined; + authorization?: string | undefined; + useDeferredClient: true; + }, + callback: callback, +): void; diff --git a/types/braintree-web/data-collector.d.ts b/types/braintree-web/data-collector.d.ts index 50ab17e6363f1c..9ee646f25970d8 100644 --- a/types/braintree-web/data-collector.d.ts +++ b/types/braintree-web/data-collector.d.ts @@ -1,10 +1,15 @@ import { Client } from "./client"; import { callback } from "./core"; -export interface DataCollector { - deviceData: string; +// We don't want to export DataCollectorBase +export {}; - rawDeviceData: object; +type MakeUndefinedIf = Condition extends true ? T | undefined : T; + +interface DataCollectorBase { + deviceData: MakeUndefinedIf; + + rawDeviceData: MakeUndefinedIf; getDeviceData(options?: { raw: boolean }): Promise; getDeviceData(options: { raw: boolean }, callback: callback): void; @@ -13,18 +18,51 @@ export interface DataCollector { teardown(callback: callback): void; } +export type DataCollector = DataCollectorBase; +export type DataCollectorDeferred = DataCollectorBase; + export function create(options: { - client: Client; + client?: Client; + authorization?: string | undefined; + useDeferredClient?: false | undefined; kount?: boolean | undefined; paypal?: boolean | undefined; riskCorrelationId?: string | undefined; + cb1?: string | undefined; }): Promise; + +export function create(options: { + client?: Client; + authorization?: string | undefined; + useDeferredClient: true; + kount?: boolean | undefined; + paypal?: boolean | undefined; + riskCorrelationId?: string | undefined; + cb1?: string | undefined; +}): Promise; + export function create( options: { - client: Client; + client?: Client; + authorization?: string | undefined; + useDeferredClient?: false | undefined; kount?: boolean | undefined; paypal?: boolean | undefined; riskCorrelationId?: string | undefined; + cb1?: string | undefined; }, callback: callback, ): void; + +export function create( + options: { + client?: Client; + authorization?: string | undefined; + useDeferredClient: true; + kount?: boolean | undefined; + paypal?: boolean | undefined; + riskCorrelationId?: string | undefined; + cb1?: string | undefined; + }, + callback: callback, +): void; diff --git a/types/braintree-web/hosted-fields.d.ts b/types/braintree-web/hosted-fields.d.ts index df94f44503a39d..5dcb5bc861cf40 100644 --- a/types/braintree-web/hosted-fields.d.ts +++ b/types/braintree-web/hosted-fields.d.ts @@ -44,6 +44,8 @@ export interface HostedFieldsField { container?: string | HTMLElement | undefined; placeholder?: string | undefined; type?: string | undefined; + iframeTitle?: string | undefined; + internalLabel?: string | undefined; formatInput?: boolean | undefined; maskInput?: boolean | HostedFieldsFieldMaskInput | undefined; select?: boolean | { options: string[] } | undefined; @@ -189,11 +191,30 @@ export interface HostedFieldsAccountDetails { lastFour: string; } +export type HostedFieldsTokenizeValues = "Yes" | "No" | "Unknown"; + +export interface HostedFieldsBinData { + commercial: HostedFieldsTokenizeValues; + countryOfIssuance: string; + debit: HostedFieldsTokenizeValues; + durbinRegulated: HostedFieldsTokenizeValues; + healthcare: HostedFieldsTokenizeValues; + issuingBank: string; + payroll: HostedFieldsTokenizeValues; + prepaid: HostedFieldsTokenizeValues; + productId: string; + business: HostedFieldsTokenizeValues; + consumer: HostedFieldsTokenizeValues; + purchase: HostedFieldsTokenizeValues; + corporate: HostedFieldsTokenizeValues; +} + export interface HostedFieldsTokenizePayload { nonce: string; details: HostedFieldsAccountDetails; type: string; description: string; + binData: HostedFieldsBinData; /** * Provides details about regulatory environment. * See https://developer.paypal.com/braintree/docs/guides/3d-secure/migration/javascript/v3#authentication-insight. @@ -337,6 +358,7 @@ export interface HostedFields { */ tokenize(options?: { vault?: boolean | undefined; + authenticationInsight?: { merchantAccountId: string } | undefined; fieldsToTokenize?: Array | undefined; cardholderName?: string | undefined; billingAddress?: HostedFieldsBillingAddress | undefined; @@ -344,6 +366,7 @@ export interface HostedFields { tokenize( options: { vault?: boolean | undefined; + authenticationInsight?: { merchantAccountId: string } | undefined; fieldsToTokenize?: Array | undefined; cardholderName?: string | undefined; billingAddress?: HostedFieldsBillingAddress | undefined; @@ -361,7 +384,8 @@ export interface HostedFields { * } * }); */ - addClass(field: string, classname: string, callback?: callback): void; + addClass(field: HostedFieldsHostedFieldsFieldName, classname: string): Promise; + addClass(field: HostedFieldsHostedFieldsFieldName, classname: string, callback: callback): void; /** * Removes a class to a {@link module:braintree-web/hosted-fields~field field}. Useful for updating field styles when events occur elsewhere in your checkout. * @@ -376,7 +400,8 @@ export interface HostedFields { * hostedFieldsInstance.removeClass('number', 'custom-class'); * }); */ - removeClass(field: string, classname: string, callback?: callback): void; + removeClass(field: HostedFieldsHostedFieldsFieldName, classname: string): Promise; + removeClass(field: HostedFieldsHostedFieldsFieldName, classname: string, callback: callback): void; /** * Sets the placeholder of a {@link module:braintree-web/hosted-fields~field field}. * @@ -400,7 +425,8 @@ export interface HostedFields { * } * }); */ - setPlaceholder(field: string, placeholder: string, callback?: callback): void; + setPlaceholder(field: HostedFieldsHostedFieldsFieldName, placeholder: string): Promise; + setPlaceholder(field: HostedFieldsHostedFieldsFieldName, placeholder: string, callback: callback): void; /** * @example @@ -415,7 +441,8 @@ export interface HostedFields { * hostedFieldsInstance.clear('cvv'); * hostedFieldsInstance.clear('expirationDate'); */ - clear(field: string, callback?: callback): void; + clear(field: HostedFieldsHostedFieldsFieldName): Promise; + clear(field: HostedFieldsHostedFieldsFieldName, callback: callback): void; /** * Returns an {@link HostedFields~stateObject|object} that includes the state of all fields and possible card types. @@ -437,7 +464,28 @@ export interface HostedFields { * } * }); */ - focus(field: HostedFieldsHostedFieldsFieldName, callback?: callback): void; + focus(field: HostedFieldsHostedFieldsFieldName): Promise; + focus(field: HostedFieldsHostedFieldsFieldName, callback: callback): void; + + /** + * Get card verification challenges, such as requirements for cvv and postal code. + * @example + * hostedFieldsInstance.getChallenges().then(function (challenges) { + * challenges // ['cvv', 'postal_code'] + * }); + */ + getChallenges(): Promise; + getChallenges(callback: callback): void; + + /** + * Get supported card types configured in the Braintree Control Panel + * @example + * hostedFieldsInstance.getSupportedCardTypes().then(function (cardTypes) { + * cardTypes // ['Visa', 'American Express', 'Mastercard'] + * }); + */ + getSupportedCardTypes(): Promise; + getSupportedCardTypes(callback: callback): void; /** * Sets an attribute of a {@link module:braintree-web/hosted-fields~field field}. @@ -473,7 +521,8 @@ export interface HostedFields { * * @returns Returns a promise if no callback is provided. */ - setAttribute(options: HostedFieldAttributeOptions, callback?: callback): void; + setAttribute(options: HostedFieldAttributeOptions): Promise; + setAttribute(options: HostedFieldAttributeOptions, callback: callback): void; /** * Removes a supported attribute from a {@link module:braintree-web/hosted-fields~field field}. @@ -495,7 +544,8 @@ export interface HostedFields { * * @returns Returns a promise if no callback is provided. */ - removeAttribute(options: HostedFieldAttributeOptions, callback?: callback): void; + removeAttribute(options: HostedFieldAttributeOptions): Promise; + removeAttribute(options: HostedFieldAttributeOptions, callback: callback): void; /** * Sets a visually hidden message (for screen readers) on a {@link module:braintree-web/hosted-fields~field field}. @@ -517,6 +567,30 @@ export interface HostedFields { * }); */ setMessage(options: HostedFieldMessageOptions): void; + + /** + * Sets the month options for the expiration month field when presented as a select element. + * + * @param options An array of 12 entries corresponding to the 12 months. + * + * @example Update the month options to spanish + * hostedFieldsInstance.setMonthOptions([ + * '01 - enero', + * '02 - febrero', + * '03 - marzo', + * '04 - abril', + * '05 - mayo', + * '06 - junio', + * '07 - julio', + * '08 - agosto', + * '09 - septiembre', + * '10 - octubre', + * '11 - noviembre', + * '12 - diciembre' + * ]); + */ + setMonthOptions(options: ReadonlyArray): Promise; + setMonthOptions(options: ReadonlyArray, callback: callback): void; } /** @@ -551,14 +625,20 @@ export function create(options: { client?: Client | undefined; authorization?: string | undefined; fields: HostedFieldFieldOptions; - styles?: any; + styles?: Record> | undefined; + preventAutofill?: boolean | undefined; + binVerificationLength?: 6 | 8 | undefined; + sessionId?: string | undefined; }): Promise; export function create( options: { client?: Client | undefined; authorization?: string | undefined; fields: HostedFieldFieldOptions; - styles?: any; + styles?: Record> | undefined; + preventAutofill?: boolean | undefined; + binVerificationLength?: 6 | 8 | undefined; + sessionId?: string | undefined; }, callback: callback, ): void; diff --git a/types/braintree-web/index.d.ts b/types/braintree-web/index.d.ts index 96379c88cde532..f1e5fa9b4d6c22 100644 --- a/types/braintree-web/index.d.ts +++ b/types/braintree-web/index.d.ts @@ -1,6 +1,7 @@ import { AmericanExpress, create as americanExpressCreate } from "./american-express"; import { ApplePay, + ApplePayDeferred, ApplePayDetails, ApplePayLineItem, ApplePayLineItemType, @@ -15,8 +16,13 @@ import { } from "./apple-pay"; import { Client, create as clientCreate, CreditCardInfo } from "./client"; import { BraintreeError, callback, VERSION } from "./core"; -import { create as dataCollectorCreate, DataCollector } from "./data-collector"; -import { create as googlePaymentCreate, GooglePayment, GooglePaymentTokenizePayload } from "./google-payment"; +import { create as dataCollectorCreate, DataCollector, DataCollectorDeferred } from "./data-collector"; +import { + create as googlePaymentCreate, + GooglePayment, + GooglePaymentDeferred, + GooglePaymentTokenizePayload, +} from "./google-payment"; import { create as hostedFieldsCreate, HostedFieldFieldOptions, @@ -68,6 +74,7 @@ export const venmo: PaymentClient; export { AmericanExpress, ApplePay, + ApplePayDeferred, ApplePayDetails, ApplePayLineItem, ApplePayLineItemType, @@ -83,8 +90,10 @@ export { Client, CreditCardInfo, DataCollector, + DataCollectorDeferred, FetchPaymentMethodsPayload, GooglePayment, + GooglePaymentDeferred, GooglePaymentTokenizePayload, HostedFieldFieldOptions, HostedFields, diff --git a/types/braintree-web/package.json b/types/braintree-web/package.json index 7153dea89d73bb..8f44cb0cac0889 100644 --- a/types/braintree-web/package.json +++ b/types/braintree-web/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@types/braintree-web", - "version": "3.96.9999", + "version": "3.143.9999", "projects": [ "https://github.com/braintree/braintree-web" ], diff --git a/types/braintree-web/test/node.ts b/types/braintree-web/test/node.ts index ba13e289c9787c..2a050dd799eaad 100644 --- a/types/braintree-web/test/node.ts +++ b/types/braintree-web/test/node.ts @@ -88,6 +88,8 @@ braintree.client.create( ".valid": { color: "green", }, + + ".invalid": "braintree-invalid-class", }, fields: { number: { @@ -100,6 +102,8 @@ braintree.client.create( cvv: { selector: "#cvv", type: "password", + iframeTitle: "CVV iframe title", + internalLabel: "CVV internal label", }, cardholderName: { container: "#cardholder-name", @@ -128,6 +132,9 @@ braintree.client.create( select: true, }, }, + preventAutofill: false, + binVerificationLength: 6, + sessionId: "my-session-id", }, (hostedFieldsErr?: braintree.BraintreeError, hostedFieldsInstance?: braintree.HostedFields) => { if (hostedFieldsErr) { @@ -138,6 +145,8 @@ braintree.client.create( return; } + hostedFieldsInstance.getChallenges().then((challenges) => console.log(challenges.join(", "))); + const form = new HTMLFormElement(); form.addEventListener( @@ -202,6 +211,7 @@ braintree.client.create( billingAddress: { postalCode: "12345", }, + authenticationInsight: { merchantAccountId: "mid" }, }, (tokenizeErr: braintree.BraintreeError, payload: braintree.HostedFieldsTokenizePayload) => { if (tokenizeErr) { @@ -228,6 +238,11 @@ braintree.client.create( hostedFieldsInstance.removeClass("number", "custom-class"); }); + (async () => { + await hostedFieldsInstance.addClass("number", "custom-class"); + await hostedFieldsInstance.removeClass("number", "custom-class"); + })(); + hostedFieldsInstance.setPlaceholder( "number", "4111 1111 1111 1111", @@ -384,6 +399,22 @@ braintree.client.create( }; }); + // Check that apple pay createPaymentRequest fields are optional + braintree.applePay.create( + { authorization: clientToken, useDeferredClient: true }, + (createErr, applePayInstance) => { + const request = { + total: { label: "Your Label", amount: "10.00" }, + }; + + (async () => { + const paymentRequest = await applePayInstance.createPaymentRequest(request); + console.log(paymentRequest); + // { total: { }, countryCode: 'US', currencyCode: 'USD', merchantCapabilities: [ ], supportedNetworks: [ ] } + })(); + }, + ); + braintree.paypal.create( { client: clientInstance, @@ -608,6 +639,17 @@ braintree.client.create( }); }); + braintree.dataCollector + .create({ + authorization: clientToken, + useDeferredClient: true, + }) + .then(dataCollectorInstance => dataCollectorInstance.getDeviceData()) + .then(deviceData => { + // Implementation + console.log(deviceData); + }); + braintree.dataCollector .create({ client: clientInstance }) .then(dataCollectorInstance => dataCollectorInstance.getDeviceData()) @@ -648,6 +690,17 @@ braintree.client.create( { client: clientInstance, version: "2-bootstrap3-modal", + cardinalSDKConfig: { + logging: { + level: "off", + }, + timeout: 5000, + maxRequestRetries: 2, + payment: { + displayLoading: true, + displayExitButton: true, + }, + }, }, (createError, threeDSecure) => { threeDSecure.verifyCard( @@ -655,6 +708,22 @@ braintree.client.create( nonce: existingNonce, amount: "123.45", // $ExpectType string bin: "1234", + accountType: "debit", + cardAddChallengeRequested: false, + challengeRequested: false, + dataOnlyRequested: false, + requestVisaDAF: false, + merchantName: "My merchant", + requestedExemptionType: "low_value", + applySmartAuthentication: false, + customFields: { + foo: 1, + bar: "a string", + }, + onLookupComplete: (data, next) => { + console.log(data); + next(); + }, collectDeviceData: true, addFrame: (err, iframe) => { // Set up your UI and add the iframe. @@ -702,6 +771,15 @@ braintree.client.create( verifyPayload.threeDSecureInfo.status; // boolean }, ); + + (async () => { + const verifyPayload = await threeDSecure.cancelVerifyCard(); + + verifyPayload.nonce; // The nonce returned from the 3ds lookup call + verifyPayload.liabilityShifted; // boolean + verifyPayload.liabilityShiftPossible; + verifyPayload.threeDSecureInfo.status; // boolean + })(); }, ); }, diff --git a/types/braintree-web/test/web.ts b/types/braintree-web/test/web.ts index 6a8e8d49cb7c53..649a61b93a907e 100644 --- a/types/braintree-web/test/web.ts +++ b/types/braintree-web/test/web.ts @@ -160,6 +160,7 @@ braintree.client.create( ".valid": { color: "green", }, + ".invalid": "braintree-invalid-class", }, fields: { number: { @@ -172,6 +173,8 @@ braintree.client.create( cvv: { container: "#cvv", type: "password", + iframeTitle: "CVV iframe title", + internalLabel: "CVV internal label", }, cardholderName: { container: "#cardholder-name", @@ -200,6 +203,9 @@ braintree.client.create( select: true, }, }, + preventAutofill: false, + binVerificationLength: 6, + sessionId: "my-session-id", }, (hostedFieldsErr?: braintree.BraintreeError, hostedFieldsInstance?: braintree.HostedFields) => { if (hostedFieldsErr) { @@ -210,6 +216,8 @@ braintree.client.create( return; } + hostedFieldsInstance.getChallenges().then((challenges) => console.log(challenges.join(", "))); + const form = new HTMLFormElement(); form.addEventListener( @@ -279,6 +287,7 @@ braintree.client.create( billingAddress: { postalCode: "12345", }, + authenticationInsight: { merchantAccountId: "mid" }, }, (tokenizeErr: braintree.BraintreeError, payload: braintree.HostedFieldsTokenizePayload) => { if (tokenizeErr) { @@ -305,6 +314,11 @@ braintree.client.create( hostedFieldsInstance.removeClass("number", "custom-class"); }); + (async () => { + await hostedFieldsInstance.addClass("number", "custom-class"); + await hostedFieldsInstance.removeClass("number", "custom-class"); + })(); + hostedFieldsInstance.setPlaceholder( "number", "4111 1111 1111 1111", @@ -583,6 +597,22 @@ braintree.client.create( }; }); + // Check that apple pay createPaymentRequest fields are optional + braintree.applePay.create( + { authorization: clientToken, useDeferredClient: true }, + (createErr, applePayInstance) => { + const request = { + total: { label: "Your Label", amount: "10.00" }, + }; + + (async () => { + const paymentRequest = await applePayInstance.createPaymentRequest(request); + console.log(paymentRequest); + // { total: { }, countryCode: 'US', currencyCode: 'USD', merchantCapabilities: [ ], supportedNetworks: [ ] } + })(); + }, + ); + braintree.paypal.create( { client: clientInstance, @@ -1017,6 +1047,17 @@ braintree.client.create( }); }); + braintree.dataCollector + .create({ + authorization: clientToken, + useDeferredClient: true, + }) + .then(dataCollectorInstance => dataCollectorInstance.getDeviceData()) + .then(deviceData => { + // Implementation + console.log(deviceData); + }); + braintree.dataCollector .create({ client: clientInstance }) .then(dataCollectorInstance => dataCollectorInstance.getDeviceData()) @@ -1057,6 +1098,17 @@ braintree.client.create( { client: clientInstance, version: "2-bootstrap3-modal", + cardinalSDKConfig: { + logging: { + level: "off", + }, + timeout: 5000, + maxRequestRetries: 2, + payment: { + displayLoading: true, + displayExitButton: true, + }, + }, }, (createError, threeDSecure) => { threeDSecure.verifyCard( @@ -1064,6 +1116,22 @@ braintree.client.create( nonce: existingNonce, amount: "123.45", // $ExpectType string bin: "1234", + accountType: "debit", + cardAddChallengeRequested: false, + challengeRequested: false, + dataOnlyRequested: false, + requestVisaDAF: false, + merchantName: "My merchant", + requestedExemptionType: "low_value", + applySmartAuthentication: false, + customFields: { + foo: 1, + bar: "a string", + }, + onLookupComplete: (data, next) => { + console.log(data); + next(); + }, collectDeviceData: true, addFrame: (err, iframe) => { // Set up your UI and add the iframe. @@ -1129,6 +1197,15 @@ braintree.client.create( }, ); + (async () => { + const verifyPayload = await threeDSecure.cancelVerifyCard(); + + verifyPayload.nonce; // The nonce returned from the 3ds lookup call + verifyPayload.liabilityShifted; // boolean + verifyPayload.liabilityShiftPossible; + verifyPayload.threeDSecureInfo.status; // boolean + })(); + threeDSecure.on("lookup-complete", (data, next) => { console.log("data from lookup", data); console.log("version", data.lookup.threeDSecureVersion); diff --git a/types/braintree-web/three-d-secure.d.ts b/types/braintree-web/three-d-secure.d.ts index eb6a58467a8737..25173d15fb96d9 100644 --- a/types/braintree-web/three-d-secure.d.ts +++ b/types/braintree-web/three-d-secure.d.ts @@ -143,7 +143,16 @@ export interface ThreeDSecureVerifyOptions { nonce: string; amount: string; bin: string; + accountType?: string; + cardAddChallengeRequested?: boolean | undefined; challengeRequested?: boolean | undefined; + dataOnlyRequested?: boolean | undefined; + requestVisaDAF?: boolean | undefined; + merchantName?: string | undefined; + requestedExemptionType?: "low_value" | "transaction_risk_analysis" | undefined; + applySmartAuthentication?: boolean | undefined; + customFields?: Record | undefined; + onLookupComplete?: ((data: ThreeDSecureVerificationData, next: () => void) => void) | undefined; /** * If set to `true`, device data such as browser screen dimensions, language and time zone is submitted with lookup data. */ @@ -187,6 +196,16 @@ export type ThreeDSecureEvent = | "authentication-modal-render" | "authentication-modal-close"; +export interface ThreeDSecureCardinalSDKConfig { + logging?: any; + timeout?: number | undefined; + maxRequestRetries?: number | undefined; + payment?: { + displayLoading?: any; + displayExitButton?: any; + } | undefined; +} + export interface ThreeDSecureCreateOptions { authorization?: string | undefined; /** @@ -203,6 +222,7 @@ export interface ThreeDSecureCreateOptions { */ version?: 1 | "1" | 2 | "2" | "2-bootstrap3-modal" | "2-inline-iframe" | undefined; client?: Client | undefined; + cardinalSDKConfig?: ThreeDSecureCardinalSDKConfig | undefined; } export interface ThreeDSecure { @@ -268,7 +288,8 @@ export interface ThreeDSecure { * verifyPayload.liabilityShiftPossible; // boolean * }); */ - cancelVerifyCard(callback: callback): void; + cancelVerifyCard(): Promise; + cancelVerifyCard(callback: callback): void; /** * Gather the data needed for a 3D Secure lookup call. @@ -292,7 +313,8 @@ export interface ThreeDSecure { /** * Cleanly tear down anything set up by {@link module:braintree-web/three-d-secure.create|create} */ - teardown(callback?: callback): void; + teardown(): Promise; + teardown(callback: callback): void; /** * Subscribes a handler function to a named event. diff --git a/types/ndarray/index.d.ts b/types/ndarray/index.d.ts index b78fb6374bedd6..13eb9a3ff4ea62 100644 --- a/types/ndarray/index.d.ts +++ b/types/ndarray/index.d.ts @@ -34,6 +34,7 @@ declare namespace ndarray { type MaybeBigInt64Array = InstanceType; type MaybeBigUint64Array = InstanceType; + type MaybeFloat16Array = InstanceType; type Data = T extends number ? GenericArray | T[] | TypedArray : T extends bigint ? GenericArray | T[] | MaybeBigInt64Array | MaybeBigUint64Array @@ -47,6 +48,7 @@ declare namespace ndarray { | Uint8ClampedArray | Uint16Array | Uint32Array + | MaybeFloat16Array | Float32Array | Float64Array; @@ -59,6 +61,7 @@ declare namespace ndarray { : D extends Uint8ClampedArray ? "uint8_clamped" : D extends Uint16Array ? "uint16" : D extends Uint32Array ? "uint32" + : D extends MaybeFloat16Array ? "float16" : D extends Float32Array ? "float32" : D extends Float64Array ? "float64" : D extends MaybeBigInt64Array ? "bigint64" diff --git a/types/ndarray/ndarray-tests.ts b/types/ndarray/ndarray-tests.ts index b3cecee20a8046..9bd124223ea497 100644 --- a/types/ndarray/ndarray-tests.ts +++ b/types/ndarray/ndarray-tests.ts @@ -103,3 +103,25 @@ function bigintDtype(arr: ndarray.NdArray>): "generic" | "a function stringDtype(arr: ndarray.NdArray>): "generic" | "array" { return arr.dtype; } + +// TypeScript's float16 lib is `esnext.float16` in 5.8/5.9 and `es2025.float16` +// in 6.0, and absent before 5.8, so no `/// ` covers +// every version dtslint checks. Declaring the global exercises +// MaybeFloat16Array on all of them; this package's tsconfig never loads a +// float16 lib, so there is nothing to conflict with. +declare global { + interface Float16Array { + readonly length: number; + [index: number]: number; + } + var Float16Array: { + prototype: Float16Array; + new(values: readonly number[]): Float16Array; + from(values: readonly number[]): Float16Array; + }; +} + +function float16Dtype(arr: ndarray.NdArray): "float16" { + return arr.dtype; +} +console.log(float16Dtype(ndarray(Float16Array.from([1.5, -2.5]), [2]))); diff --git a/types/ndarray/package.json b/types/ndarray/package.json index fafd309a600652..d61647209c4037 100644 --- a/types/ndarray/package.json +++ b/types/ndarray/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@types/ndarray", - "version": "1.0.9999", + "version": "1.1.9999", "projects": [ "https://github.com/scijs/ndarray", "https://github.com/mikolalysenko/ndarray"