GetStream / stream-chat-js

JS / Browser Client - Build Chat with GetStream.io
https://getstream.io/chat/
Other
178 stars 77 forks source link

Type error in client.ts #1198

Closed DmitryMarkov closed 2 weeks ago

DmitryMarkov commented 9 months ago

Hello, after update to version 8.12.0, I receive this tsc error in my project, what can I do here?

$ tsc -p tsconfig.json --noEmit --pretty
node_modules/stream-chat/src/client.ts:1784:45 - error TS2345: Argument of type 'string | ChannelData<StreamChatGenerics>' is not assignable to parameter of type 'string'.
  Type 'ChannelData<StreamChatGenerics>' is not assignable to type 'string'.

1784     return this.getChannelById(channelType, channelIDOrCustom, custom);
                                                 ~~~~~~~~~~~~~~~~~

Found 1 error in node_modules/stream-chat/src/client.ts:1784

Running on node 18, This is my tsconfig.json:

{
  "compilerOptions": {
    "allowJs": false,
    "allowSyntheticDefaultImports": true,
    "alwaysStrict": true,
    "baseUrl": "./src",
    "checkJs": false,
    "declaration": false,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "jsx": "react",
    "lib": ["dom", "esnext"],
    "module": "esnext",
    "moduleResolution": "node",
    "noImplicitAny": true,
    "noImplicitReturns": false,
    "noImplicitThis": true,
    "noStrictGenericChecks": false,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "outDir": "dist",
    "paths": {
      "components/*": ["components/*"],
      "containers/*": ["containers/*"],
      "enums/*": ["enums/*"],
      "microapps/*": ["microapps/*"],
      "pages/*": ["pages/*"],
      "router/*": ["router/*"],
      "store/*": ["store/*"],
      "utils/*": ["utils/*"]
    },
    "pretty": true,
    // Keep comments for webpackChunkNames.
    "removeComments": false,
    "resolveJsonModule": true,
    "rootDir": ".",
    "skipLibCheck": true,
    "sourceMap": true,
    "strictNullChecks": false,
    "target": "es2018"
  },
  "exclude": ["public", "node_modules", "dist"],
  "include": ["src"]
}
tarasom commented 8 months ago

Can someone from your team react on this? It's impossible to use your SDK in TS project

rnavarych commented 8 months ago

Will be great to know solution for that. We have the same issue...

MartinCupela commented 2 weeks ago

@DmitryMarkov apology for late reply. I see in your tsconfig.json file that you exclude node_modules but typescript is still performing check in node_modules? Could it be that you have imports other than from 'stream-chat' in your project?

MartinCupela commented 2 weeks ago

I suspect that the reason for tsc compiling node_modules is an import from stream-chat/src or similar. When you import directly from library/src, you are bypassing the typical entry points that would usually point to precompiled code (like main or module fields in package.json). This causes TypeScript to treat these as part of your project's source code, triggering a compilation.

DmitryMarkov commented 2 weeks ago

@MartinCupela thank you, that's exact the cause - we had one direct typings import. Now it's not throwing this error