Closed alexgorbatchev closed 5 months ago
@kearfy could you please check this PR?
Hey @alexgorbatchev, I tried to see if I get the same error as you with a couple of typescript versions, but I'm unable to reproduce this issue. Could you try to update your typescript version, possibly to a nightly or beta to see if the issue still presents itself? The type is intended to be inferred, and we really should not need to set a return type for that method. Thank you!
@kearfy i'm using TS 5.3.3. I don't think being on nightly should be a requirement for this package to work. Your users probably won't be running on nightly during regular development.
Getting this module to work without deno is somewhat painful tbh... my tsconfig.json
{
"compilerOptions": {
"lib": ["DOM", "ESNext"],
"outDir": "./dist",
"experimentalDecorators": true,
"noEmit": true,
"allowImportingTsExtensions": true,
"paths": {
"npm:zod@^3.22.4": ["./node_modules/zod"],
"npm:unws": ["./node_modules/unws"]
}
},
"include": ["./src/**/*"]
}
❯ npm ls typescript
surrealdb.js@ /home/alex/development/github/surrealdb.js
└── typescript@5.3.3
❯ npm exec tsc --project=./tsconfig.json` produces
node_modules/unws/src/index.d.ts:1:10 - error TS2661: Cannot export 'WebSocket'. Only local declarations can be exported from a module.
1 export { WebSocket, type MessageEvent }
~~~~~~~~~
node_modules/unws/src/index.d.ts:1:26 - error TS2661: Cannot export 'MessageEvent'. Only local declarations can be exported from a module.
1 export { WebSocket, type MessageEvent }
~~~~~~~~~~~~
src/strategies/http.ts:204:21 - error TS2347: Untyped function calls may not accept type arguments.
204 const res = await this.request<InvalidSQL | MapQueryResult<T>>("/sql", {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
205 body: query,
~~~~~~~~~~~~~~~
...
216 ),
~~~~~~
217 });
~~~~
src/strategies/http.ts:230:23 - error TS2347: Untyped function calls may not accept type arguments.
230 const [res] = await this.request<[QueryResult<ActionResult<T>[]>]>(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
231 url,
~~~~~~~
...
234 },
~~~~~
235 );
~~~
src/strategies/http.ts:252:23 - error TS2347: Untyped function calls may not accept type arguments.
252 const [res] = await this.request<[QueryResult<ActionResult<T, U>[]>]>(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
253 url,
~~~~~~~
...
257 },
~~~~~
258 );
~~~
src/strategies/http.ts:277:23 - error TS2347: Untyped function calls may not accept type arguments.
277 const [res] = await this.request<[QueryResult<ActionResult<T, U>[]>]>(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
278 url,
~~~~~~~
...
282 },
~~~~~
283 );
~~~
src/strategies/http.ts:302:23 - error TS2347: Untyped function calls may not accept type arguments.
302 const [res] = await this.request<[QueryResult<ActionResult<T, U>[]>]>(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
303 url,
~~~~~~~
...
307 },
~~~~~
308 );
~~~
src/strategies/http.ts:323:23 - error TS2347: Untyped function calls may not accept type arguments.
323 const [res] = await this.request<[QueryResult<ActionResult<T>[]>]>(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
324 url,
~~~~~~~
...
327 },
~~~~~
328 );
~~~
Found 8 errors in 2 files.
Errors Files
2 node_modules/unws/src/index.d.ts:1
6 src/strategies/http.ts:204
Ignoring errors in node_modules
, the other errors are in src/strategies/http.ts
, which is what I'm trying to fix with this PR.
Update on this, since deno can simply import packages from NPM we'll likely convert this back to a normal NodeJS project. I've found that Deno can sometimes act flaky, where types resolve in one place but not in the other, which could also be the reason that this was an issue for you but not for me!
It would be useful to merge this in the meanwhile, it's been 2 months.
Hey @alexgorbatchev, I've been unable to reproduce this issue in the old library, and we've since revamped the library. If you can still reproduce this issue somehow, feel free to let me know. I will be closing your PR however in the meantime
What is the motivation?
Types are currently broken resulting
.status
and.result
to be unavailable when library is used when using TypeScript 5.3.2.What does this change do?
Fixes the types.
What is your testing strategy?
Verifying with TypeScript.
Is this related to any issues?
Have you read the Contributing Guidelines?