Skip to content

Class method autocompletions not working properly on class with mixins #26275

Open
@mjbvz

Description

@mjbvz

From @Floriferous on August 6, 2018 20:25

When composing a class together through mixins, the intellisense autocompletion does not work properly:

// @flow
/* eslint-env mocha */
import { expect } from 'chai';
import { compose } from 'recompose';

class RootCalculator {
  constructor() {
    this.initializer = 2;
  }

  add(a: number, b: number): number {
    return a + b;
  }

  returnVarParent() {
    return this.var;
  }

  return2(): number {
    return 2;
  }

  parentFunc() {
    return this.childFunc();
  }
}

const withCalc2 = (SuperClass = class {}) =>
  class extends SuperClass {
    constructor() {
      super();
      this.initializer = this.initializer * 2;
    }

    increment(a: number): number {
      return a + 1;
    }

    setVar(value): void {
      this.var = value;
    }
  };

const withCalc3 = SuperClass =>
  class extends SuperClass {
    constructor() {
      super();
      this.initializer = this.initializer + 1;
    }

    multiply(a: number, b: number): number {
      return a * b;
    }

    returnVarChild(): void {
      return this.var;
    }

    return2(): number {
      return -2;
    }

    childFunc() {
      return 'it works';
    }
  };

const UberClass = compose(
  withCalc3,
  withCalc2,
)(RootCalculator);

const calculator = new UberClass();

calculator. // Wait for autocomplete, it can't find the class methods, or suggests them after plenty of other stuff

screen shot 2018-08-06 at 22 24 33

Copied from original issue: microsoft/vscode#55910

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions