-
Notifications
You must be signed in to change notification settings - Fork 23
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
Using esnext
as target breaks some decoding
#76
Comments
More information, since I ran into it again.
|
I faced a similar issue when exploring the usage of a via CLI generated contract file in an example app included in the wharfkit-wallet-plugin-template where following {
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"experimentalDecorators": true,
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
} the {
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
} I generated the contract for import { APIClient as AntelopeAPIClient } from '@wharfkit/antelope'
import { Contract as AtomicMarketContract } from "./atomicmarket"
const antelopeClient = new AntelopeAPIClient({ url: "https://proton.eosusa.io" })
const amContract = new AtomicMarketContract({client: antelopeClient, account: 'atomicmarket'})
const userBalance = await amContract.table('balances').get(session!.actor.toString())
console.log(userBalance) the output of (an existing balance row) is:
|
I was able to get it working with |
I think I figured this out - it's the outputted struct classes and incompatibility with Take for example this struct: @Struct.type('propose')
class Propose extends Struct {
@Struct.field(Name) proposer!: Name
} With However, if you change the struct to the format below, the values now populate correctly. @Struct.type('propose')
class Propose extends Struct {
@Struct.field(Name) declare proposer: Name
} It's prepending the property name with Any already generated structs will need to be modified to include this change. We'll update our libraries and make the command line tools use this syntax. |
The If there's any instances of this still happening - feel free to reopen the issue. |
Just stumbled into this in a nodejs project, when setting
"target": "esnext"
in thetsconfig.json
, it prevents some structs from rendering properly.Sample code:
This causes the output to be:
However when I switch to using
"target": "es2020"
, the same code above outputs:Not sure what in
esnext
breaks this, and not sure if we need to fix - but recording here for sake of jotting it down somewhere.The text was updated successfully, but these errors were encountered: