microsoft / microsoft/TypeScript

Imperative type definition

Open
#62,145 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

🔍 Search Terms

imperative typescript interface

✅ Viability Checklist
⭐ 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.

imperative type Foo<T> {
  type X = Bar<T>;
  type Y = Baz<T>;

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

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

// ... vs
interface Foo<T> {
  x: Bar<T>;
  y: Baz<T>;
}
💻 Use Cases
  • Imperative style
  • Shorter syntax for complex types

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No implementation file, entry point, or test is identified. Start by reviewing the proposed syntax and motivating examples against TypeScript's design goals, then inspect the type-checker architecture to determine where such a type-level feature would fit; done requires an agreed design and corresponding implementation and 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
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.