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

Docs: NoInfer #390

Open
Beraliv opened this issue May 1, 2024 · 0 comments
Open

Docs: NoInfer #390

Beraliv opened this issue May 1, 2024 · 0 comments

Comments

@Beraliv
Copy link
Collaborator

Beraliv commented May 1, 2024

What

NoInfer was introduced in TypeScript 5.4 and prohibits inferring literals

It needs to be documented in ts-essentials for completeness

Examples

declare function createFSM<TState extends string>(config: {
  initial: NoInfer<TState>;
  states: TState[];
}): TState;

createFSM({
  // Type '"not-allowed"' is not assignable to type '"open" | "closed"' 🔴
  initial: "not-allowed",
  states: ["open", "closed"],
});

createFSM({
  initial: "initial",
  states: ["initial", "open", "closed"],
});

Additional Info

https://www.totaltypescript.com/noinfer

@Beraliv Beraliv added enhancement New feature or request v10.1 docs and removed enhancement New feature or request labels May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant