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

1 messages · Page 1 of 1 (latest)

vagrant lynx
#

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:

            "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!

dusky swan
#

@vagrant lynx

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

vagrant lynx
#

Hi @dusky swan ! 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

Minimal reproducible error for typescript + novu use of node types - crispamares/novu-minimal-node-ts-error

dusky swan
#

@novu/shared pacakge is required in server side as well because it has shared enums, interfaces, dtos