Skip to content

"Did you mean" spelling suggestions can offer the same thing being complained about #25564

Closed
@RyanCavanaugh

Description

@RyanCavanaugh

TypeScript Version: 2.92

Search Terms: did you mean spelling suggestion same

Code

type NonVoid = Object | object;

type Something<T> = { test: string } & (T extends NonVoid ? {
    requiredWhenNonVoid: T
} : {
    requiredWhenNonVoid?: undefined
    });

function testFunc2<A extends NonVoid>(a: A): Something<A> {
    return {
        test: 'test',
        requiredWhenNonVoid: a
//      ~~~~~~~~~~~~~~~~~~~
    };
}

Expected behavior: Probably no error, or at least not this error suggestion

Actual behavior:

clipboard.ts:12         requiredWhenNonVoid: a
                        ~~~~~~~~~~~~~~~~~~~~~~
  TS2322: Type '{ test: string; requiredWhenNonVoid: A; }' is not assignable to type 'Something<A>'.
    Object literal may only specify known properties, but 'requiredWhenNonVoid' does not exist in type 'Something<A>'. Did you mean to write 'requiredWhenNonVoid'?

There's no spelling error here -- the requiredWhenNonVoid being cited is the same requiredWhenNonVoid being suggested 🤡

Playground Link: Link

Related Issues: Nope

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions