language-typescript icon indicating copy to clipboard operation
language-typescript copied to clipboard

Type generics for React components break syntax highlighting

Open kaiyoma opened this issue 5 years ago • 1 comments

Prerequisites

Steps to Reproduce

Enter this text and set the type to "TypeScriptReact":

// Add all the single-select stories first.
ALL_OPTIONS.forEach(({ name, options, stateKey }) => {
  storiesOf('Select', module).add(`Single value - ${name}`, () => (
    <State store={store}>
      {(state: PlainObject<string | string[]>) => (
        <Select<unknown>
          className='select-story-component'
        />
      )}
    </State>
  ));
});

// Add all the multi-select stories next.
ALL_OPTIONS.forEach(({ name, options, stateKey }) => {
  storiesOf('Select', module).add(`Multiple values - ${name}`, () => (
    <State store={store}>
      {(state: PlainObject<string | string[]>) => (
        <Select<unknown>
          className='select-story-component'
        />
      )}
    </State>
  ));
});

Actual behavior:

image

Reproduces how often:

100%

Versions

$ atom --version

Atom    : 1.45.0
Electron: 4.2.7
Chrome  : 69.0.3497.128
Node    : 10.11.0

kaiyoma avatar Apr 28 '20 19:04 kaiyoma

I'm having a similar issue with class mixins

// highlighting works, class is underspecified
import { ApolloQuery } from '@apollo-elements/lit-apollo';
class QueryComponent extends AnalysisQueryMixin(ApolloQuery) { // No base constructor has the specified number of type arguments.
  static readonly is = 'broken-highlighting';
  render() {
    html`
      <strong>highlighting is broken here</strong>
    `
  }
}
// highlighting broken, class is typed up properly
import { ApolloQuery } from '@apollo-elements/lit-apollo';
class QueryComponent extends AnalysisQueryMixin(ApolloQuery)<Data, Variables> {
  static readonly is = 'broken-highlighting';
  render() {
    html`
      <strong>highlighting works here</strong>
    `
  }
}

this works though

const AnalysisElement = AnalysisQueryMixin(ApolloQuery)
class QueryComponent extends AnalysisElement<Data, Variables> {/*...*/}

bennypowers avatar Aug 03 '20 15:08 bennypowers