aws / amazon-chime-sdk-js

A JavaScript client library for integrating multi-party communications powered by the Amazon Chime service.
Apache License 2.0
699 stars 472 forks source link

SDK Does not Pass the Typechecker #2848

Open dairyisscary opened 4 months ago

dairyisscary commented 4 months ago

What happened and what did you expect to happen?

The file node_modules/amazon-chime-sdk-js/build/signalingprotocol/SignalingProtocol.d.ts does not pass typescript typechecker. I have elided the output but there are 22 instances of this same error:

node_modules/amazon-chime-sdk-js/build/signalingprotocol/SignalingProtocol.d.ts:7:26 - error TS2709: Cannot use namespace 'Long' as a type.

7     timestampMs: (number|Long);
                           ~~~~

node_modules/amazon-chime-sdk-js/build/signalingprotocol/SignalingProtocol.d.ts:89:33 - error TS2709: Cannot use namespace 'Long' as a type.

89     public timestampMs: (number|Long);
                                   ~~~~

Versions:

yarn why -R long
   └─ amazon-chime-sdk-js@npm:3.20.0 (via npm:^3.20.0)
      └─ protobufjs@npm:7.2.6 (via npm:^7.2.4)
         └─ long@npm:5.2.3 (via npm:^5.0.0)

yarn info typescript
└─ typescript@patch:typescript@npm%3A5.3.3#optional!builtin<compat/typescript>::version=5.3.3&hash=e012d7
   ├─ Version: 5.3.3

skipLibCheck is false in my project

I did a manual patch of SignalingProtocol.d.ts to change and it seems to compile

-import Long = require("long");
+import type Long from "long";

Have you reviewed our existing documentation?

Reproduction steps

yarn run tsc as a downstream project that checks libs with "skipLibCheck": false in one's tsconfig.json

Amazon Chime SDK for JavaScript version

posted above

What browsers are you seeing the problem on?

n/a

Browser version

n/a

Meeting and Attendee ID Information.

No response

Browser console logs

n/a

ltrung commented 3 months ago

What typescript version are you using?

dairyisscary commented 3 months ago

As specificed in the original issue, this was produced in typescript version 5.3.3, though it still appears to be the case in 5.4.x.

I have made a minmalist reproduction with a replit here: https://replit.com/@dairyisscary/Aws-sdk-reproduction?v=1#tsconfig.json

i think that some combination of the tsconfig.json configuration options module, moduleResolution and of course, skipLibCheck: false are what make the semantics of this particular line import Long = require("long"); invalid here. 🤷