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

Arrow function with generics can get strange syntax highlighting #672

Closed
csvn opened this issue Oct 1, 2018 · 1 comment
Closed

Arrow function with generics can get strange syntax highlighting #672

csvn opened this issue Oct 1, 2018 · 1 comment

Comments

@csvn
Copy link

csvn commented Oct 1, 2018

TS and JS Grammar Extension version: 0.0.45 / latest

Code

export function computed<K extends string | symbol>(...watchedProps: K[]) {
  if (watchedProps.length < 1) throw new Error('@computed() decorator must have at least one property argument');

  return <V, T extends Record<K, any>>(
    _target: T,
    _prop: string | symbol,
    desc: TypedPropertyDescriptor<V>
  ) => {
    if (!desc.get) throw new Error('The `@computed()` decorator must be used on `get` method.');
    if (desc.set) throw new Error('The `@computed()` decorator cannot be used with `set` method.');
    if (desc.value) throw new Error('The `@computed()` decorator cannot be used with a regular function.');
    // ....
  };
}

I am making a @computed() decorator (caches result until one of the provided props changes), and I stumbled upon this weird coloring issue when I split up a long line. My guess is that it has something to do with TSX/JSX.

image

image

@csvn
Copy link
Author

csvn commented Oct 1, 2018

Wow, that was quick. Nice going @sheetalkamat!

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