Typescript: Bad completions for string literal type as indexed access type object

Created on 30 Aug 2020  路  5Comments  路  Source: microsoft/TypeScript

Found while reading over #39697

let x: ""["bar"]

Request completions inside of "" and you'll get the names of every propery on String. What's happening is that we're not checking to see if the current string literal type is the argument type (as opposed to the object type itself).

Learning how this works might be a bit involved, but the fix is easy: add fourslash tests, add a single if check at https://github.com/microsoft/TypeScript/blob/d75894d85b8fd5f83116d3c02b5ba30a62af4348/src/services/stringCompletions.ts#L117-L124

Bug Completion Lists good first issue help wanted

Most helpful comment

@DanielRosenwasser I would like to take this issue as my first issue. Here are the fourslash tests I have currently: fourslashTests. Am I going in the right direction? Thank you

All 5 comments

@DanielRosenwasser I would like to take this issue as my first issue. Here are the fourslash tests I have currently: fourslashTests. Am I going in the right direction? Thank you

I haven't used the array versions of marker, but if that test is currently failing on the first verify call, I think you're on the right track!

Has the issue been resolved?

Has the issue been resolved?

@denismaxim0v No, I am still on it

Thanks @Vboivin!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kyasbal-1994 picture kyasbal-1994  路  3Comments

Zlatkovsky picture Zlatkovsky  路  3Comments

blendsdk picture blendsdk  路  3Comments

siddjain picture siddjain  路  3Comments

dlaberge picture dlaberge  路  3Comments