Closed adrianhdez929 closed 2 months ago
I will add a fix for the networks.json
file, but we should use camelCase
or snake_case
for mapping keys, this is the discussion open. I personally will go for camelCase
in this one, but in that case (a lot of cases, this looks like a switch-case statement
XD) we should choose between uppercase
or lowercase
for the key starting character
We should avoid using "-" character in any mapping key string in the future, since there is no valid character in TS/JS for variable naming, so when trying to import i.e: "taraxa-testnet", from
networks.json
file it throws error.
please, provide the error details and the code snippet
These is because we don't access networks.json
directly, instead we use a NetworkConfig
, but anyway I don't see a reason to use a problematic style so for convenience maybe we should change it anyway.
I agree with @adrianhdez929 about camelCase
because typescript don't use snake_case
to name anything
We should avoid using "-" character in any mapping key string in the future, since there is no valid character in TS/JS for variable naming, so when trying to import i.e: "taraxa-testnet", from
networks.json
file it throws error.please, provide the error details and the code snippet
I think that @adrianhdez929 refers to the fact that we can't
import { network } from "./networks.json" ;
If network
is a network with a name containing -
we won't be able to import it that way. When creating these i personally use -
to be consistent with the filename style that we use before and because I personally use it like
import networks from "./networks.json" ;
networks["taraxa-testnet"] // with autocompletion
I use it like that and I don't have any problem, but it is true that there is a potential incovenience with the -
because it force to use networks
like the 2 code snippet
@MakeMake23 exactly what @TheSnakeWitcher said up there, there are ways to round the issue, because this is not widely adapted (at least not yet), but if we don't change this, we can only access an Object
with keys kebab case
as a dictionary and not directly call their members with the usual dot
notation Object.member
We should avoid using "-" character in any mapping key string in the future, since there is no valid character in TS/JS for variable naming, so when trying to import i.e: "taraxa-testnet", from
networks.json
file it throws error.please, provide the error details and the code snippet
I think that @adrianhdez929 refers to the fact that we can't
import { network } from "./networks.json" ;
If
network
is a network with a name containing-
we won't be able to import it that way. When creating these i personally use-
to be consistent with the filename style that we use before and because I personally use it likeimport networks from "./networks.json" ; networks["taraxa-testnet"] // with autocompletion
I use it like that and I don't have any problem, but it is true that there is a potential incovenience with the
-
because it force to usenetworks
like the 2 code snippet
Actually what we can't do is:
import { taraxa-testnet } from "./networks.json";
We should avoid using "-" character in any mapping key string in the future, since there is no valid character in TS/JS for variable naming, so when trying to import i.e: "taraxa-testnet", from
networks.json
file it throws error.