question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Flow type arguments at callsites in class bodies

See original GitHub issue

This flow language feature is broken in class bodies (and possibly elsewhere, I haven’t looked):

screen shot 2019-02-28 at 2 40 39 pm

class Correct extends React.Component<MyProps> {
  myRef = React.createRef();

  render() {
    const {foo} = this.props;
    return null;
  }
}

class NotCorrect extends React.Component<MyProps> {
  myRef = React.createRef<HTMLDivElement>(); // This causes the problem!

  render() {
    const {foo} = this.props;
    return null;
  }
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:10
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
michaelgmcdcommented, Jul 31, 2019

The > character is the issue. When inspecting the TM scope, it seems like it’s being treated as the > of an arrow function (meta.function.arrow.js) which seems to break all of the syntax highlighting until the next } (end of the make believe function. This might be a little tricky to debug, but I’ll try to take a look when I can.

1reaction
rattrayalex-stripecommented, Sep 11, 2019

Yep, looks perfect! Screen Shot 2019-09-11 at 8 34 59 AM

Read more comments on GitHub >

github_iconTop Results From Across the Web

Announcing Bounded Polymorphism - JavaScript. Flow
As of Flow 0.5.0, you can define polymorphic functions and classes with bounds on their type parameters. This is extremely useful for ...
Read more >
Generic Types | Flow
Classes can create generics by placing the type parameter list before the body of the class. ... You can use generics in the...
Read more >
Function Types | Flow
Function Parameters. Function parameters can have types by adding a colon : followed by the type after the name of the parameter.
Read more >
Class Types - JavaScript. Flow
Typing classes and using classes as types. ... Just like in functions, class methods can have annotations for both parameters (input) and returns...
Read more >
Give Type a type argument such that T is Type<T> #2090
This issue is a proposal to change the built-in class Type such that it accepts a single type parameter with no bound, and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found