N
Novu5mo ago
luna

Typescript is throwing an error with functions shared between DOM & NodeJS

Hello!! We installed novu@notification-center (v0.23.0) to start using Novu. Everything works fine, but our typescript is throwing this error: Type 'Timeout' is not assignable to type 'Number'. It seems like Typescript does not know if Timeout comes from the DOM or nodeJS. In our tsconfig.ts, we specified the types & lib like this:
"lib": [
"ES2021",
"DOM"
],
"types": [
"jest",
"react",
"react-dom",
"route-parser"
],
"lib": [
"ES2021",
"DOM"
],
"types": [
"jest",
"react",
"react-dom",
"route-parser"
],
We removed the '@types/node' from our package-json to see what package may be causing the issue, and we found it in @novu/shared, where it was added using the triple slash directive: /// <reference types="node />" Can we fix this on our side? Are we missing something? Thank you!
No description
No description
4 Replies
Pawan Jain
Pawan Jain5mo ago
@luna Could you please share minimum reproducible code in a github repo? I have doubt that there is some more dependency in your project that may cause this issue
luna
luna5mo ago
Hi @Pawan Jain ! Thank you for replying. One of my coworkers set up a repo with just a few dependencies (react, types & typescript), and you can see that the '@types/node' dependency is required. Here is the link: https://github.com/crispamares/novu-minimal-node-ts-error Because the 'shared' package can be used on the client side, it shouldn't import the node types, right?
GitHub
GitHub - crispamares/novu-minimal-node-ts-error: Minimal reproducib...
Minimal reproducible error for typescript + novu use of node types - crispamares/novu-minimal-node-ts-error
Pawan Jain
Pawan Jain5mo ago
@novu/shared pacakge is required in server side as well because it has shared enums, interfaces, dtos
luna
luna5mo ago
so if I want to use the notification-center frontend component in an application where I only have the client side & typescript, I have to deal with that typescript error. Is that right?