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.

Name clash when extending Component in TypeScript

See original GitHub issue

We have a custom component, similar to this one:

export class SomeNode extends Component {

  public static nodeName = 'TheNode';

  constructor() {
    super(SomeNode.nodeName);
  }

  async builder(node: Node) {
    return node;
  }

  worker(node: Node, inputs: IOs, outputs: IOs, ...args: any): any {
  }
}

Now our compiler gets massive problems parsing which type Node is which. The type in worker is not the same as the one in builder. The easiest fix would be if you named your classes with different names and not have multiple classes with the name Component or Node.

Btw, it would be easie to subclass based on my needs if I could extend worker optionally. In our project, we only need the designing features, but no tasks or workers at all.

Or do you have an easy solution for me, which does not involve aliasing all the imports?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Ni55aNcommented, May 16, 2019

Please check the v1.3.1-rc.1

1reaction
pszalanskicommented, May 16, 2019

Quite easy: As soon as I have to type Something as SomethingElse it means that there is a name clash. And this should never happen in the same library. IDEs and code editors usually cannot handle this, because the alias is a custom name invented by me, the programmer. Simply rename the class in your library and automatically importing needed classes works automatically.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Making your components extensible with TypeScript
In this article I'm gonna focus on how to make your components extensible in TypeScript. By extensible I mean, extending your original ...
Read more >
Is there a way to extend a third party library type with same ...
Oh, yeah I think you're right, there will be a name clash. Does this link help? Import two classes with the same name...
Read more >
Documentation - Namespaces - TypeScript
Instead of putting lots of different names into the global namespace, let's wrap up our objects into a namespace. In this example, we'll...
Read more >
React Higher-Order Components in TypeScript - Medium
ClassComponent<P> , meaning the component that is passed into the HOC can be either a function component or class component. class WithLoading extends...
Read more >
Useful Patterns by Use Case - React TypeScript Cheatsheets
export interface ButtonProps extends React. ... Usecase: same as above, but for a React Component you don't have access to the underlying props....
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