You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is no problems while writing or compiling in visual studio. It shows the constructor's arguments too.
I saw many pages about the solution of the "TypeError: ... is not a constructor" error (like changing the import line, changing source, etc) but none of them helps about this!
The other classes in the project and capnproto objects have not this problem and I'm using them as normal with "new" construction.
So what's the problem with Message.ts file?!
Update:
I checked another way of changing import line now. I used this for import a message:
and used "new Message()" instead of "new capnp.Message()"
But that solves the problem for the Message class itself and there are many classes inside project like that, need similar changes!
So it raises now a new error inside the message.js file:
TypeError: arena_1.SingleSegmentArena is not a constructor
And if I solve it there will be another one :D
So I know the problem is in the generated js files, and the problem may be resolved by changing entire capnp-ts module, but why all this incompatibility happened?! And how can I fix it without changing module source files?!
I reinstalled the module via npm but nothing changed.
Hi
I installed capnp-ts in my visual studio 2022 angular12 project.
when I simply want to use "new capnp.Message()" method as in its documentation, it raises this error on browser:
The code is just like github readme file:
import * as capnp from "capnp-ts";
import { MyStruct } from "./myschema.capnp.js";
export function loadMessage(buffer: ArrayBuffer): MyStruct {
const message = new capnp.Message(buffer);
return message.getRoot(MyStruct);
}
But inside the Message.ts file, it has a normal constructor :
https://github.com/jdiaz5513/capnp-ts/blob/master/packages/capnp-ts/src/serialization/message.ts
There is no problems while writing or compiling in visual studio. It shows the constructor's arguments too.
I saw many pages about the solution of the "TypeError: ... is not a constructor" error (like changing the import line, changing source, etc) but none of them helps about this!
The other classes in the project and capnproto objects have not this problem and I'm using them as normal with "new" construction.
So what's the problem with Message.ts file?!
Update:
I checked another way of changing import line now. I used this for import a message:
const Message = require('capnp-ts/src/serialization/message.js').Message;
and used "new Message()" instead of "new capnp.Message()"
But that solves the problem for the Message class itself and there are many classes inside project like that, need similar changes!
So it raises now a new error inside the message.js file:
And if I solve it there will be another one :D
So I know the problem is in the generated js files, and the problem may be resolved by changing entire capnp-ts module, but why all this incompatibility happened?! And how can I fix it without changing module source files?!
I reinstalled the module via npm but nothing changed.
Stackoverflow link for this question:
https://stackoverflow.com/questions/70764851
The text was updated successfully, but these errors were encountered: