microsoft / microsoft/TypeScript

Imperative type definition

Offen
#62,145 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Awaiting More Feedback Suggestion
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
2 T. 4 Std.
Gemergte PRs (30 T.)
132

Beschreibung

### 🔍 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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Es ist keine Implementierungsdatei, kein Einstiegspunkt und kein Test angegeben. Beginne damit, die vorgeschlagene Syntax und die motivierenden Beispiele anhand der Designziele von TypeScript zu überprüfen, und untersuche anschließend die Architektur des Type-Checkers, um festzustellen, wo ein solches Feature auf Type-Ebene hineinpassen würde; als abgeschlossen gilt die Aufgabe, wenn ein abgestimmtes Design sowie die entsprechende Implementierung und Tests vorliegen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
compilers
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.