I have
import * as yargs from 'yargs'
let args = yargs
.option('address', {
alias: 'a',
description: "address",
demand: true,
type: "string"
})
.option('network', {
alias: 'n',
description: "network",
demand: true,
type: "string"
}).argv
console.log(args)
After running the script with yarn ts-node script.ts --address 0x3cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c --network flare
I get
{
_: [],
address: '0x3cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c',
a: '0x3cb7d3842e8cee6a0ebd09f1fe884f6861e1b29c',
network: 'flare',
n: 'flare',
'$0': 'node_modules\\ts-node\\dist\\bin.js'
}
But then when I try to access members e.g. argv.address
it throws me a typescript compilation error
TSError: ⨯ Unable to compile TypeScript:
src/toPChainAddress.ts:19:18 - error TS2339: Property 'a' does not exist on type '{ [x: string]: unknown; address: string; network: string; _: (string | number)[]; $0: string; } | Promise<{ [x: string]: unknown; address: string; network: string; _: (string | number)[]; $0: string; }>'.
Property 'a' does not exist on type 'Promise<{ [x: string]: unknown; address: string; network: string; _: (string | number)[]; $0: string; }>'.
19 console.log(args.a)