# this.updateWires() is not a function

**URL:** <https://discourse.nodered.org/t/this-updatewires-is-not-a-function/58106>\
**Category:** Developing Nodes\
**Created:** [10 February 2022 20:55 UTC](https://discourse.nodered.org/t/this-updatewires-is-not-a-function/58106 "2022-02-10T20:55:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wz2b](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wz2b/32/55839_2.png) [@wz2b](https://discourse.nodered.org/u/wz2b)\
**Post date:** [10 February 2022 20:55 UTC](https://discourse.nodered.org/t/this-updatewires-is-not-a-function/58106/1 "2022-02-10T20:55:37Z")

</div>

Hi,

I understand that typescript support in node red is a bit sketchy, but in some tests I have gotten it to work really well. I find it really clean, and it lets me test and use these classes in other places. My ultimate goal is to make the logic fairly unaware of node red, except for a little glue needed to create objects in the NR universe.

What I'm trying to do is clean up some of the object instantiation around this. I started with what was done [here](https://medium.com/@bernardo.belchior1/node-red-creating-a-custom-node-using-typescript-5f4fd0127d44) and [here](https://www.technicalfeeder.com/2021/07/how-to-implement-node-red-node-in-typescript/) and both of those together gave me a great start.

Unfortunately, I'm doing something wrong, because I get this:

`10 Feb 15:31:28 - [error] [gis-powermon-ll:15fee740e28a2bda] TypeError: this.updateWires is not a function`

This suggests that createNode() is not actually attaching Node to the instance as I expect it should. Let me explain the code. First, there is an (empty) base class. Its only real purpose is so that when createNodes() calls the javascript superclass that the typescript compiler believes that extension (or sub-classing, whatever you want to call it) results in a fully typed object. I really think of it more as a mix-in. So the base class looks like this:

```auto
import { Node as NodeRedNode, NodeDef, NodeAPI } from "node-red";

export abstract class NRTSNode {}
export interface NRTSNode extends NodeRedNode {}

```

For those not familiar, declaring an abstract class and then an interface _with the exact same name_ is a form of [interface merging](https://www.typescriptlang.org/docs/handbook/declaration-merging.html), a feature of typescript. What it does here is lets me refer to objects in NodeRedNode (an alias I made for a NodeRed "Node").

Next, I created my actual class:

```auto
class PowermonLinkLayerNode extends NRTSNode {
    private waiting_for_flag: boolean = true;
    private escaped: boolean = false;
    private buffer: Array<number> = [];

    constructor(RED: NodeAPI, config: GisPowermonLLNodeDef) {
        super();
        RED.nodes.createNode(this, config);
    }
   ...

```

The call to RED.nodes.createNode() is explained in the documentation very well:

```auto
// call createNode()
// Called from a Node's constructor function,
// invokes the super-class constructor and attaches
// any credentials to the node.
// Params:
// node – the node object being created
// def – the instance definition for the node

```

So, in conjunction with the interface merging, I should now have my own class that is overlayed with the Node interface for typing purposes, and the call to createNode should attach all the missing pieces of "Node" the base class. This is as I understand a fairly common way to have a Typescript class that extends a javascript class. So far so good.

Finally, to create a node, I need to register it as usual. I want to have the actual logic implemented by the TypeScript class, so:

```auto
export = (RED: NodeAPI): void => {
    function createMyVerySpecialNode(config: GisPowermonLLNodeDef) {
        let instance = new PowermonLinkLayerNode(RED, config);
        instance.on("input", (msg: any, send, done) => {
            instance.onInput(msg)
        })
    }
    RED.nodes.registerType("gis-powermon-ll", createMyVerySpecialNode);
}

```

However, when I actually try to run this on a flow, I get ` this.updateWires is not a function` and I'm not really sure why. My interpretation of the documentation is the function exported by the ts file registers the new type with `(name, static_constructor_function)` and that is what happens - when I place a node on a flow this inner function gets called; if I place two of the same nodes it gets called twice. However it seems to fail out. It fails in _my_ constructor, either in `createNode()` or immediately after, I'm not sure.

I'd prefer people not reply trying to talk me out of using Typescript. This is as much an intellectual exercise as a useful one. I appreciate that it might be useful to me and just more complication to others. But if anybody out there has some thoughts on how I can proceed to debug this please reply. I feel like this is very close to working.

[EDIT] [THIS CODE](https://github.com/node-red/node-red/blob/2eff7da1715a0b3035149ba4a09880590837fb9c/packages/node_modules/%40node-red/runtime/lib/nodes/index.js#L93) is what I think is the right `.createNode()` and I'm not sure what this:

```auto
function createNode(node,def) {
    Node.call(node,def);

```

which looks like it's calling [this guy](https://github.com/node-red/node-red/blob/2eff7da1715a0b3035149ba4a09880590837fb9c/packages/node_modules/%40node-red/runtime/lib/nodes/Node.js#L37) that ends in:

```auto
this.updateWires(n.wires);

```

so that's definitely where the problem is coming from. I think that my class is not really a Node (even though it's declared as such). I must be missing a step.

--Chris

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [11 April 2022 20:55 UTC](https://discourse.nodered.org/t/this-updatewires-is-not-a-function/58106/2 "2022-04-11T20:55:51Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [14 June 2026 14:15 UTC](https://discourse.nodered.org/t/this-updatewires-is-not-a-function/58106/3 "2026-06-14T14:15:39Z")

</div>



---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [14 June 2026 14:18 UTC](https://discourse.nodered.org/t/this-updatewires-is-not-a-function/58106/4 "2026-06-14T14:18:41Z")

</div>

Resurrecting this because I'm getting the same problem with Node-RED v5 and a node defined as an ES Module.

Has anyone else come across this issue? Anyone know the reason for it?

I'm trying this on a really simple node - my inline-debug which is mostly a copy of the core debug node. You can imagine that I don't really want to start work on a major revamp of something more complex if I'm not sure what is going wrong.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [14 June 2026 14:30 UTC](https://discourse.nodered.org/t/this-updatewires-is-not-a-function/58106/5 "2026-06-14T14:30:59Z")

</div>

And I think I already have the answer.

It seems to be because there isn't a `this` object that represents the node instance until _after_ `RED.nodes.createNode(this, config)` has been called.

So you have to be quite careful where you put references to `this` if you want to reference the node instance.

So now I'm back to trying to track down why my node instance seems to get created but shows up as  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/0/b053b275d86a0d68b86c5f24a0c2fdc4606d70e9.png)  
in the Editor. There are no errors in the node-red log nor in the Editor.
