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?