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.

Use # prefix on private class field with eslint-plugin-flowtype cause "Cannot read property 'type' of undefined"

See original GitHub issue

Bug Report

Clone of https://github.com/babel/babel-eslint/issues/688

As reported by @SebastienGllmt:

This exact issue still persists for me even if I crank all eslint & bable dependencies to their latest version. What’s more, this doesn’t always fail. For example in my case

This fails

  #publicDeriverId: number;
  #bip44Wallet: IBip44Wallet;
  #derivationId: number;
  #pathToPublic: Array<number>; // only this specific private field causes an error.

This passes

  #publicDeriverId: number;
  #bip44Wallet: IBip44Wallet;
  #derivationId: number;
  #pathToPublic: string; // note: this changed

Adding this totally unrelated type makes it work

type TotallyUnrelatedType = Array<number>;
export class Foo {
  #publicDeriverId: number;
  #bip44Wallet: IBip44Wallet;
  #derivationId: number;
  #pathToPublic: Array<number>;
}

_Originally posted by @SebastienGllmt in https://github.com/babel/babel-eslint/issues/688#issuecomment-531608020_

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
kaicataldocommented, Oct 19, 2020

Hey, sorry for the delay here. Do you mind sharing the versions of all @babel/core, eslint, @babel/eslint-parser, and eslint-plugin-flowtype you’re using as well as the actual output from ESLint for the various examples? It’ll make it easier to understand what is going on.

1reaction
JLHwungcommented, Mar 19, 2021

We can not enable the class features by default since it is a breaking change to ecosystem (but it is inevitable since Babel AST differs to ESTree). If you want to try on this feature

module.exports = {
  parser: "@babel/eslint-parser",
  babelOptions: {
    parserOpts: {
      plugins: [
        ["estree", { classFeatures: true }],
        "classPrivateProperties",
        "classProperties",
      ],
    },
  },
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Use # prefix on private class field with eslint-plugin-flowtype ...
Use # prefix on private class field with eslint-plugin-flowtype cause "Cannot read property 'type' of undefined" #688.
Read more >
TypeError: Cannot read property 'prefix' of undefined
I'm using Fortawesome and found this thread but I am using and importing the icons correctly. The thing is I try and use...
Read more >
Private class features - JavaScript - MDN Web Docs - Mozilla
Private class features. Class fields are public by default, but private class members can be created by using a hash # prefix. The...
Read more >
Playground Example - Private Class Fields - TypeScript
3.8 adds private fields, which are a way of declaring a class field to be ... using an instance of the class to...
Read more >
@babel/plugin-transform-for-of | Yarn - Package Manager
#11096 Wrap type-only class fields in flow comments (@nicolo-ribaudo) ... #10557 fix: disable caching when babel could not read/write cache. (@JLHwung) ...
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