Skip to content

Cannot be used to index type in 3.9 (worked in 3.8) #38740

Description

TypeScript Version: 3.9.3

Search Terms:

cannot be used to index type

Code

2536

// A *self-contained* demonstration of the problem follows...
// works in 3.8, fails in 3.9// Is this a bug in 3.9?// Nexus (nexusjs.org) depended on this functionalitytypeGet1<Aextendsany,Bextendsany,Cextends'filtering'|'ordering'>=AextendskeyofStuff
? BextendskeyofStuff[A]
? Stuff[A][B][C]// error here
: never
: never;interfaceStuff{// [k:string]: any // <-- Putting this here fixes Get1 in TS 3.9Blog: {// [k:string]: any // <-- Putting this here fixes Get1 in TS 3.9 posts: {filtering: 'a',ordering: 'b'}}}

Expected behavior:

TS 3.9 supports the same type logic as in 3.8 (see playground repro)

Actual behavior:

Breaks in 3.9 (our context: graphql-nexus/nexus#859)

Playground Link:

link

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions