js-stellar-sdk icon indicating copy to clipboard operation
js-stellar-sdk copied to clipboard

StellarTomlResolver.resolve should offer better types

Open ryanleecode opened this issue 6 years ago • 4 comments

Is your feature request related to a problem? Please describe. Its annoying when I try to parse the stellar.toml file with StellarTomlResolver and the resulting type defintion is { [key: string]: any }.

Describe the solution you'd like Extend the definition to include common stellar.toml fields.

Example:

interface StellarTOML {
  AUTH_SERVER: string;
  FEDERATION_SERVER: string;
  /** etc... */
  [key: string]: any;
}

Describe alternatives you've considered Making it readonly is also probably justified

interface StellarTOML {
  readonly AUTH_SERVER: string;
  readonly FEDERATION_SERVER: string;
  /** etc... */
  readonly [key: string]: any;
}

ryanleecode avatar Jul 12 '19 05:07 ryanleecode

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I have 7 years of typescript development experience

How I plan on tackling this issue

` interface StellarTOML { readonly AUTH_SERVER: string; readonly FEDERATION_SERVER: string; readonly TRANSFER_SERVER?: string; readonly KYC_SERVER?: string; readonly WEB_AUTH_ENDPOINT?: string; readonly SIGNING_KEY?: string; readonly HORIZON_URL?: string; // Additional readonly fields can be added here as needed

readonly [key: string]: any; // Readonly support for other fields } `

smartdev914 avatar Oct 04 '24 01:10 smartdev914

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I'm a javascript/Typescript developer

How I plan on tackling this issue

so my approach to this will be that: The essential fields like AUTH_SERVER and FEDERATION_SERVER are marked as readonly and required. example interface StellarTOML{ readonly AUTH_SERVER: string; readonly FEDERATION_SERVER: string;

//Then, optional well-known fields can be as:// readonly TRANSFER_SERVER?: string; readonly WEB_AUTH_ENDPOINT?: string; readonly KYC_SERVER?: string; readonly SIGNING_KEY?: string; readonly HORIZON_URL?: string; readonly ACCOUNTS?: string[];

//finally, other fields can be allowed dynamically with strict types as:// readonly [key: string]: string | number | boolean | null | undefined | string[]; }

This approach can improve code intellsense, type safet and flexibility.

Jethrolopwus avatar Oct 24 '24 09:10 Jethrolopwus

Can I jump on this task?

devJaja avatar Nov 21 '24 16:11 devJaja

Could I try solving this?

mimisavage avatar Nov 28 '24 13:11 mimisavage

Looks to be addressed in #794

Ryang-21 avatar Nov 13 '25 18:11 Ryang-21