Skip to content

Conversation

@snoack
Copy link
Contributor

@snoack snoack commented Jan 6, 2024

This change is Reviewable

Copy link
Contributor Author

@snoack snoack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion


index.d.ts line 7 at r1 (raw file):

  static readonly DONT_RETRY: unique symbol;

  constructor(options?: Options & TParams);

Storing options and parameters in the same object isn't ideal. The type of new Hubkit({method: 'POST'}) is inferred as Hubkit<{method: string}>, even though method is a property of Options, hence the type should rather be just Hubkit<{}>. I think in practice this won't cause any trouble, e.g. when explicitly defining types since the type Hubkit<{redundantPropertyFromOptions: any}> can still be assigned to the type Hubkit<{}>. Though it's causing confusing type information to be inferred in VSCode and error messages.

Copy link
Member

@pkaminski pkaminski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No complaints about the changes here, but I'd like to see how it all comes together in client code before merging anything.

Reviewed all commit messages.
Reviewable status: 0 of 1 files reviewed, 2 unresolved discussions (waiting on @snoack)


index.d.ts line 7 at r1 (raw file):

Previously, snoack (Sebastian Noack) wrote…

Storing options and parameters in the same object isn't ideal. The type of new Hubkit({method: 'POST'}) is inferred as Hubkit<{method: string}>, even though method is a property of Options, hence the type should rather be just Hubkit<{}>. I think in practice this won't cause any trouble, e.g. when explicitly defining types since the type Hubkit<{redundantPropertyFromOptions: any}> can still be assigned to the type Hubkit<{}>. Though it's causing confusing type information to be inferred in VSCode and error messages.

Huh, I would've expected the "specific" interface to capture properties before the wildcard one, if you get what I mean. I don't see a way around this short of completely separating options and parameters, though, which is probably way too much work.


index.d.ts line 12 at r1 (raw file):

  graph(query: string, options?: Options & {variables?: Record<string, any>}): Promise<any>;
  interpolate(string: string, options?: Parameters);
  scope<Tsource extends Parameters>(options: Options & Tsource): Hubkit<TParams & Tsource>;

Nit: Tsource -> TSource (for consistency with TParams)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants