Skip to content

Incorrect type snippet inserting with indexed access #62

@zardoy

Description

@zardoy

I have .t snippet that I use to wrap types into generics e.g. SomeType.t -> Partial<SomeType>, its really handy. However, I usually use it in combination with Extract so I can reduce amount of fields passing to the generic above e.g. Partial.

Snippet:

{
    "name": "t",
    "description": "",
    "body": "$1<{{expr}}>$2",
    "when": ["type"]
}

Works:

Extract<Config.t, ''> -> Extract<<Config>, ''>

Fails:

Extract<Config[''].t, ''> -> <Extract<Config['']>, ''> // notice incorrect insertion of opening <

The same applies for typeof:

Partial<Extract<typeof config.t, ''>> -> Partial<<Extract<typeof config>, ''>>

Expected:

Partial<Extract<typeof config.t, ''>> -> Partial<Extract<<typeof config>, ''>>

Hope I made it clear.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions