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

Supporting negative types is very convenient #55000

Closed
5 tasks
Autumn-one opened this issue Jul 13, 2023 · 2 comments
Closed
5 tasks

Supporting negative types is very convenient #55000

Autumn-one opened this issue Jul 13, 2023 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@Autumn-one
Copy link

Autumn-one commented Jul 13, 2023

Suggestion

πŸ” Search Terms

Negated types

βœ… Viability Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

Many typescript users want the ability to negate types

type NotStr = not string;

At present, typescript does not have real negative types, but if negative types can be applied in some actual development scenarios, it will be able to express types more clearly and directly. I think this is the basic function that a Type system should have. Without this function, developers may use some imprecise and complex ways to implement flexibly, which is not good
I've seen a PR that was turned off, which is a real shame
#29317

@xiBread
Copy link

xiBread commented Jul 13, 2023

Duplicate of #4196 (#29317 (comment))

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jul 13, 2023
@typescript-bot
Copy link
Collaborator

This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@typescript-bot typescript-bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants