Skip to content

typescript-vim throws syntax error for flavored strings that actually compile fine #201

@theahura

Description

@theahura

In our code base we use Flavoring: https://spin.atomicobject.com/2018/01/15/typescript-flexible-nominal-typing/
This allows us to name our string types, e.g.

type Flavoring<FlavorT> = { _type?: FlavorT; }
type Flavor<T, FlavorT> = T & Flavoring<FlavorT>;
...
type URL = Flavor<string, "URL">
type FooKey = Flavor<string, "FooKey">

now, these types are still just type string, so you can do all of the usual string indexing on dictionaries. For example:

const dict = { ... }
const key: FooKey = 'hello'
dict[key] 

and typescript compiles just fine and there are no warnings.

But typescript-vim complains:
Element implicitly has any type because expression FooKey cannot be used to index type {}

Is there a way to fix this?

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