upstash / qstash-js

Message queue for serverless
https://docs.upstash.com/qstash
MIT License
133 stars 11 forks source link

'Cannot find module' type errors on build #31

Closed lukepearce closed 1 year ago

lukepearce commented 1 year ago

Hi,

I've used the sdk (latest version 0.3.6) in a node project that's running Typescript 3.7.0.

On build, I'm getting the following errors:

node_modules/@upstash/qstash/types/deps/deno.land/std@0.177.0/crypto/_wasm/mod.d.ts:1:64 - error TS2307: Cannot find module './lib/deno_std_wasm_crypto.generated.js' or its corresponding type declarations.

1 export { DigestContext, instantiate as instantiateWasm, } from "./lib/deno_std_wasm_crypto.generated.js";
                                                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@upstash/qstash/types/pkg/client/client.d.ts:7:44 - error TS2307: Cannot find module '../../deps/raw.githubusercontent.com/microsoft/TypeScript/main/lib/lib.dom' or its corresponding type declarations.

7 import type { BodyInit, HeadersInit } from "../../deps/raw.githubusercontent.com/microsoft/TypeScript/main/lib/lib.dom";
                                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@upstash/qstash/types/pkg/client/http.d.ts:1:44 - error TS2307: Cannot find module '../../deps/raw.githubusercontent.com/microsoft/TypeScript/main/lib/lib.dom' or its corresponding type declarations.

1 import type { BodyInit, HeadersInit } from "../../deps/raw.githubusercontent.com/microsoft/TypeScript/main/lib/lib.dom";

I'm importing both client and receiver as:

import { Receiver } from "@upstash/qstash";
import { Client } from "@upstash/qstash";

my tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "esModuleInterop": true,
    "inlineSources": true,
    "target": "es6",
    "moduleResolution": "node",
    "sourceMap": true,
    "outDir": "srv",
    "baseUrl": "src",
    "lib": [
      "esnext", "dom"
    ],
    "paths": {
      "*": [
        "node_modules/*",
        "src/types/*"
      ]
    }
  },
  "include": [
    "src/**/*"
  ]
}

I've googled the issue but haven't found a clear resolution.

chronark commented 1 year ago

what runtime version are you using?

Could you create a small reproducible repo, so I can try this?

lukepearce commented 1 year ago

what runtime version are you using?

Could you create a small reproducible repo, so I can try this?

I'm using node 16.13.1.

Will set one up 👍🏼

lukepearce commented 1 year ago

I was able to replicate in this repo even with the latest version of typescript.

https://github.com/FloomLtd/upstash-test

chronark commented 1 year ago

Thanks, I'll put this on my to-do list for tomorrow morning

chronark commented 1 year ago

Adding "skipLibCheck": true, to your tsconfig.json resolves this. this is just internal types missing, to the user (you) it exports the correct types.

I'll see what I need to fix internally :)

lukepearce commented 1 year ago

Adding "skipLibCheck": true, to your tsconfig.json resolves this. this is just internal types missing, to the user (you) it exports the correct types.

I'll see what I need to fix internally :)

thanks for taking a look so quickly. builds successfully now 👌🏼 . I had no issue with the sdk itself, works great!

chronark commented 1 year ago

Great! I'll add your reproduction repo as example after I fixed it if you don't mind

lukepearce commented 1 year ago

Great! I'll add your reproduction repo as example after I fixed it if you don't mind

Yeah no problem. I can add the receiver example too if you like.