We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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:
string
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 {}
Element implicitly has any type because expression FooKey cannot be used to index type {}
Is there a way to fix this?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
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.
now, these types are still just type
string
, so you can do all of the usual string indexing on dictionaries. For example: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?
The text was updated successfully, but these errors were encountered: