Skip to content
New issue

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

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

Open
theahura opened this issue Mar 26, 2023 · 0 comments

Comments

@theahura
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant