Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infer TS type from JSON schema #463

Closed
cyrilletuzi opened this issue Oct 15, 2020 · 1 comment
Closed

Infer TS type from JSON schema #463

cyrilletuzi opened this issue Oct 15, 2020 · 1 comment

Comments

@cyrilletuzi
Copy link
Owner

cyrilletuzi commented Oct 15, 2020

Description of the issue

Currently the lib infers the TS type in get/watch from the JSON schema for simple types (string, number, boolean and array of the former), but not for complex arrays or objects, leading to:

  • a double work for the user, who must do the type and the JSON schema
  • we are not sure the type match the JSON schema

It is now possible with today's TypeScript to infer the type from the JSON schema even for complex types.

Note it requires to assert JSON schemas as const (maybe microsoft/TypeScript#30680 could help, but it doesn't seem it will get a solution from TS).

@cyrilletuzi
Copy link
Owner Author

PR #477

Blocked on Angular supporting TS 4.1 (and TS >= 4.1 only) for recursive conditional types, so probably not before Angular v12.

Also, a DX issue (no IntelliSense when writing the JSON schemas) is discussed in microsoft/TypeScript#41247, but it doesn't seem it will get a solution from TS.

@cyrilletuzi cyrilletuzi added this to the v12 milestone Nov 5, 2020
@cyrilletuzi cyrilletuzi self-assigned this Nov 10, 2020
@cyrilletuzi cyrilletuzi removed their assignment Feb 9, 2021
@cyrilletuzi cyrilletuzi removed this from the v12 milestone Feb 9, 2021
Repository owner locked and limited conversation to collaborators Feb 12, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant