microsoft / microsoft/TypeScript

Imperative type definition

Ouverte
#62,145 3 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Awaiting More Feedback Suggestion
Langage dominant
Go
Étoiles
111k
Forks
14.3k
Merge moyen
2 j 4 h
PR mergées (30 j)
132

Description

### 🔍 Search Terms

imperative typescript interface

### ✅ Viability Checklist

- [x] This wouldn't be a breaking change in existing TypeScript/JavaScript code
- [x] This wouldn't change the runtime behavior of existing JavaScript code
- [x] This could be implemented without emitting different JS based on the types of the expressions
- [x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- [x] This isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- [x] This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals

### ⭐ Suggestion

I work on a library that requires to use lots of 3rd party generic types, multiple mappings and more or less complex typing, and I've got to repeat one complex type multiple times or create another generic that is going to contain a lot of parameters and will complicate the code that's already complicated.

(these types have bugs, they just an illustration)
Image

### 📃 Motivating Example

I imagine it as an "type function" that has function body that returns any valid type.

```ts
imperative type Foo {
type X = Bar;
type Y = Baz;

return { x: X, y: Y };
}

type Quix = Foo;
// Quix { x: Bar, y: Baz }

// ... vs
interface Foo {
x: Bar;
y: Baz;
}
```

### 💻 Use Cases

- Imperative style
- Shorter syntax for complex types

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Aucun fichier d’implémentation, point d’entrée ou test n’est identifié. Commencez par examiner la syntaxe proposée et les exemples motivants au regard des objectifs de conception de TypeScript, puis inspectez l’architecture du vérificateur de types afin de déterminer où une telle fonctionnalité au niveau des types pourrait s’intégrer ; le travail sera considéré comme terminé lorsqu’une conception aura été approuvée et que l’implémentation et les tests correspondants seront disponibles.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
typescript
Domaine
compilers
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
25/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.