Name clash when extending Component in TypeScript
See original GitHub issueWe 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:
- Created 4 years ago
- Comments:6 (6 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Please check the
v1.3.1-rc.1
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.