#Is there any hope for me?
29 messages · Page 1 of 1 (latest)
the error is quite obvious
spent more time looking for the lib on npm than finding what's wrong
@solemn yew
the default export for package apache-age-client is a class
which you need to create an instance of yourself
age.connect is wrong
and should be
import { ApacheAgeClient } from "apache-age-client";
this.connectionPromise = new ApacheAgeClient().connect({});
https://www.npmjs.com/package/apache-age-client?activeTab=code
/apache-age-client/lib/index.d.ts
at line 27
nah; it does not work
Property 'connect' does not exist on type 'ApacheAgeClient'. Did you mean to access the static member 'ApacheAgeClient.connect' instead?
it isn't. the class in question is also exported as the default, and connect is a static method.
Whoops, right, missed the static modifier on that method
@cyan oriole @bronze igloo is it possible that there is some tsconfig option, that blocks the usage of class method without initialization of class?
no
but I had a look at the compile library, and it looks quite complicated for a few commonjs exports
what if you try to switch to ESM, to run the ESM version of the lib
you'd need to
- add
"type": "module" - change your tsconfig options to
"module": "ESNext"
not sure how the auth of the lib published their library, but it's possible the library is built incorrectly
Already did that
I do not know if he build it incorrectly, but i tried using pg instead ang I have got yet another error
import { Client } from "pg";
^
SyntaxError: The requested module 'pg' does not provide an export named 'Client'
at ModuleJob._instantiate (node:internal/modules/esm/module_job:132:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:214:5)
at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
at async loadESM (node:internal/process/esm_loader:28:7)
at async handleMainPromise (node:internal/modules/run_main:113:12)
even though I have @types/pg installed
maybe there is some issue with my config
that's unrelated, that's for ts. this is js complaining
import pg from "pg";
const Client = pg.Client;
Solved it with this, but omg, the typescript ecosystem is so fkd
Ok