Skip to content
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

TypeScript: any vs unknown #76

Open
TomokiMiyauci opened this issue Apr 18, 2023 · 1 comment
Open

TypeScript: any vs unknown #76

TomokiMiyauci opened this issue Apr 18, 2023 · 1 comment

Comments

@TomokiMiyauci
Copy link

Currently, empty forms are generated as any type.

In TypeScript, there are few situations where the any type is more suitable than the unknown type.

Both are tolerant of assignments.
unknown is more type-safe than any because it is strictly for reference.

I think the unknown type is better suited for the role of a code generator.

@joshgillies
Copy link

As a work around to the above, you could do something like the following to explicitly output an unknown type:

{
  "data": {
    "metadata": {
      "typescriptType": "unknown"
    }
  }
}

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

No branches or pull requests

2 participants