microsoft / microsoft/TypeScript
Negated types
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
Sometimes it is desired to forbid certain types from being considered.
Example: `JSON.stringify(function() {});` doesn't make sense and the chance is high it's written like this by mistake. With negated types we could eliminate a chance of it.
``` typescript
type Serializable = any ~ Function; // or simply ~ Function
declare interface JSON {
stringify(value: Serializable): string;
}
```
Another example
``` typescript
export NonIdentifierExpression = ts.Expression ~ ts.Identifier
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files, tests, or entry points are named. Start by reviewing the proposed Serializable and NonIdentifierExpression examples, then determine the required type-system behavior and its effects on assignability; done means negated types are supported consistently and covered by appropriate tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100