Principal reserved word as field name in candid file

I am attempting to implement the extendable token standard in TypeScript (see GitHub - lastmjs/azle: JavaScript/TypeScript CDK for the Internet Computer).

The extendable token standard implementation in Motoko has a variant with a field named principal: extendable-token/ at main · Toniq-Labs/extendable-token · GitHub

I am trying to create a hand-written candid file with that same variant:

type User = variant {
    address: text;
    principal: principal;

But I am getting an unexpected token error:

principal: principal;
  │     ^^^^^^^^^ Unexpected token
  = Expects one of "decimal", "hex", "id", "text", "}

I assume this is because principal is a reserved word in candid. But…how can I match the Motoko variant which has a variant named principal?

1 Like

You can quote the field name: "principal": principal


Thanks a lot, it works!