-
Notifications
You must be signed in to change notification settings - Fork 57
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
Wrong TS types #825
Comments
Hi @IgnatLomkov , I couldn't reproduce the issue. Could you show the logs? |
Hi, @fboucquez, you probably do not fully understand me. If you do not consider the use of transactionStatus.group in other files, then there is correct typing. Code in this comment gives me "confirmed". But type TransactionGroupEnum cannot be applied in other parts of the sdk adequately. Let's say I want to perform such an action: import { TransactionGroupEnum } from 'symbol-openapi-typescript-fetch-client'
import { RepositoryFactoryHttp } from 'symbol-sdk'
const repositoryFactory = new RepositoryFactoryHttp('http://wolf.importance.jp:3000')
const transactionRepository = repositoryFactory.createTransactionRepository()
const transactionStatusRepository = repositoryFactory.createTransactionStatusRepository()
transactionStatusRepository.getTransactionStatus('30F03BB1E2D422C19E1DEBFFB21C046EF8CD9FB32F5FF7C1A9235792162D20B1').subscribe(transactionStatus => {
console.log(transactionStatus.group) // will output "confirmed"
if(transactionStatus.group === TransactionGroupEnum.Failed) return
transactionRepository.getTransaction('30F03BB1E2D422C19E1DEBFFB21C046EF8CD9FB32F5FF7C1A9235792162D20B1', transactionStatus.group) // TS error, but "Failed" excluded
.subscribe(fullTransaction => console.log(fullTransaction))
}) There may of course be such a workaround, but it's still not what you want to use: import { TransactionGroupEnum } from 'symbol-openapi-typescript-fetch-client'
import { RepositoryFactoryHttp, TransactionGroup } from 'symbol-sdk'
const repositoryFactory = new RepositoryFactoryHttp('http://wolf.importance.jp:3000')
const transactionRepository = repositoryFactory.createTransactionRepository()
const transactionStatusRepository = repositoryFactory.createTransactionStatusRepository()
transactionStatusRepository.getTransactionStatus('30F03BB1E2D422C19E1DEBFFB21C046EF8CD9FB32F5FF7C1A9235792162D20B1').subscribe(transactionStatus => {
console.log(transactionStatus.group) // will output "confirmed"
if (transactionStatus.group === TransactionGroupEnum.Failed) return
transactionRepository.getTransaction('30F03BB1E2D422C19E1DEBFFB21C046EF8CD9FB32F5FF7C1A9235792162D20B1', transactionStatus.group as unknown as TransactionGroup)
.subscribe(fullTransaction => console.log(fullTransaction))
}) The same typing inconsistency exists in other parts of the sdk |
Thanks @IgnatLomkov , you are right. We should split the TransactionGroupEnum with and without Failed. Failed value is not a valid value when searching or loading transactions. |
Expected behavior and actual behavior
The project has a file, where is the wrong typing (group field) subject to the use of this model in this file (toTransactionStatus method). It says that the field must be of type enum, but in fact it is one of the enum values
Steps to reproduce the problem
Specifications like the version of the project, operating system, or hardware
The text was updated successfully, but these errors were encountered: