You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Your types have declare enum TokenStatus but you don't have any Javascript to implement that enum so users will break if they try to do token.status === Square.TokenStatus.OK. You should either implement the enum correctly in JS or use a union of string literal types as the type for token.status and remove the enum type entirely.
To Reproduce
Run some code that does a comparison like:
import * as Square from '@square/web-sdk'
const token = getMeAToken();
if (token.status === Square.TokenStatus.OK) {
console.log("Everything is fine");
}
Note that token.status === "OK" is technically invalid Typescript (and for most other languages) as a string value that happens to match an enum value isn't technically the same as the enum value.
Expected behavior
An enum defined using Typescript functions like an enum in JS.
A field uses a string literal union if it actually expects a specific set of string values.
Screenshots
Not applicable.
Desktop (please complete the following information):
OS: Any
Browser: Anything that runs Javascript
Version: Anything that runs Javascript
Smartphone (please complete the following information):
Again, anything that runs Javascript.
Additional context
You probably just want to make this change in payment-method-types.d.ts:
// ...interfaceTokenResult{/** * Indicates whether the tokenization request was successful. */status: "Unknown"|"OK"|"Error"|"Invalid"|"Abort"|"Cancel";// ...}// ...
Or, again, implement the enum correctly in your JS. If you built from Typescript originally, perhaps you mistakenly used a const enum or something? 🤷♀️
The text was updated successfully, but these errors were encountered:
Describe the bug
Your types have
declare enum TokenStatus
but you don't have any Javascript to implement that enum so users will break if they try to dotoken.status === Square.TokenStatus.OK
. You should either implement the enum correctly in JS or use a union of string literal types as the type fortoken.status
and remove the enum type entirely.To Reproduce
Run some code that does a comparison like:
Note that
token.status === "OK"
is technically invalid Typescript (and for most other languages) as a string value that happens to match an enum value isn't technically the same as the enum value.Expected behavior
Screenshots
Not applicable.
Desktop (please complete the following information):
Smartphone (please complete the following information):
Again, anything that runs Javascript.
Additional context
You probably just want to make this change in
payment-method-types.d.ts
:Or, again, implement the enum correctly in your JS. If you built from Typescript originally, perhaps you mistakenly used a
const enum
or something? 🤷♀️The text was updated successfully, but these errors were encountered: