microsoft / microsoft/DefinitelyTyped-tools

Generics with default and $ExpectType value

Open
#919 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
423
Forks
237
Avg merge
18h 18m
Merged PRs (30d)
11

Description

Consider the following example:

class Foo<T = number> {
    public bar: T;
}

declare const foo: Foo;

// $ExpectType Foo<number>
foo;

Should this be rendered instead as just Foo – ?

There's a situation that might motivate this further than just "it's simpler" which is that perhaps generics have been added to Foo but backwards compatibility is provided through the default type.

If a type is specified using just default types, should the tool drop those types from the output?

Contributor guide

No contributing guide indexed for this repository

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

Start with the TypeScript example and trace how the tool evaluates $ExpectType assertions. No file or test entry point is named, so first locate that handling and review existing generic-type expectations. Done means establishing whether default generic arguments should be omitted and adding coverage for the chosen behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing-qa, tooling
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.