_Pear
_Pear
Explore posts from servers
DDeno
Created by Mqx on 4/9/2024 in #help
`declare module` doesn’t work
idk why types doesn't work, may be worth opening an issue
35 replies
DDeno
Created by Mqx on 4/9/2024 in #help
`declare module` doesn’t work
I think this is the relevant documentation? https://docs.deno.com/runtime/manual/advanced/typescript/types#using-ambient-or-global-types
Using ambient or global types Overall it is better to use module/UMD type definitions with Deno, where a module expressly imports the types it depends upon. Modular type definitions can express augmentation of the global scope via the declare global in the type definition. For example:
declare global {
var AGlobalString: string;
}
declare global {
var AGlobalString: string;
}
This would make AGlobalString available in the global namespace when importing the type definition.
In some cases though, when leveraging other existing type libraries, it may not be possible to leverage modular type definitions. Therefore there are ways to include arbitrary type definitions when type checking programmes.
35 replies
DDeno
Created by Mqx on 4/9/2024 in #help
`declare module` doesn’t work
my understanding is: modules from .ts files should work, but not from d.ts files again, not sure if that is 100% accurate but it has worked for me.
35 replies
DDeno
Created by Mqx on 4/9/2024 in #help
`declare module` doesn’t work
Hi, i had similar confusion with the d.ts file and opened an issue but I didnt get much response. My issue was with namespaces. In the docs somewhere (ill try to find and link) it says that .d.ts files are treated somewhat differently than in envs we are used to. Idk why this is the case. Did you try adding a TypeScript config with the types field pointing to the d.ts file? might help but idk!
35 replies
DDeno
Created by babakfp on 4/7/2024 in #help
Good Back-end Framework?
Or you're looking for something to use with tauri but without SvelteKit? I'm a bit confused.
3 replies
DDeno
Created by babakfp on 4/7/2024 in #help
Good Back-end Framework?
SvelteKit has api routes and form handlers, is that not sufficient?
3 replies
DDeno
Created by _Pear on 3/26/2024 in #help
Help with TypeScript namespaces - is this pattern supported?
6 replies
DDeno
Created by _Pear on 3/26/2024 in #help
Help with TypeScript namespaces - is this pattern supported?
sure, I'll open one this evening. I have a reproduction attached at the link in the OP if you're able to take a look in the meantime.
6 replies
DDeno
Created by _Pear on 3/26/2024 in #help
Help with TypeScript namespaces - is this pattern supported?
When using namespaces in a .d.ts file, the deno linter does not complain. When using it in a .ts file, it will warn you to use ESmodules instead of namespaces. Could the linter be enhanced to give the same warning in d.ts files?
6 replies
DDeno
Created by cdoremus on 3/26/2024 in #help
Is there a way to bundle multiple files into one file using `esbuild_deno_loader` and `esbuild`?
tsup is a wrapper aroundn esbuild and rollup and it can output to a single file, might be what you're after? https://tsup.egoist.dev/#bundle-files
20 replies
DDeno
Created by _Pear on 9/9/2023 in #help
KV list is returning an empty iterator, but data is there and gettable via get
Very confused but it seems to be working now w/Hono. Not entirely sure why. Thanks 🙂
6 replies
DDeno
Created by _Pear on 9/9/2023 in #help
KV list is returning an empty iterator, but data is there and gettable via get
Where it's not working for me behind a Hono route so there may be something there I'm missing, I'll report back if I figure it out.
6 replies
DDeno
Created by _Pear on 9/9/2023 in #help
KV list is returning an empty iterator, but data is there and gettable via get
Hmmm it seems to work fine in this isolated example:
export const Db = await Deno.openKv("./kv/kv-repro.db");

const makeAccounts = async () => {
const accounts = [
{
username: "test1",
},
{
username: "test2",
},
{
username: "test3",
},
{
username: "test4",
},
];

for (const account of accounts) {
await Db.set(["accounts", account.username], account);
}
};


const listAccounts = async () => {
const iter = Db.list({ prefix: ["accounts"] });
for await (const row of iter) {
console.log(row);
}
};

await makeAccounts();
await listAccounts();
export const Db = await Deno.openKv("./kv/kv-repro.db");

const makeAccounts = async () => {
const accounts = [
{
username: "test1",
},
{
username: "test2",
},
{
username: "test3",
},
{
username: "test4",
},
];

for (const account of accounts) {
await Db.set(["accounts", account.username], account);
}
};


const listAccounts = async () => {
const iter = Db.list({ prefix: ["accounts"] });
for await (const row of iter) {
console.log(row);
}
};

await makeAccounts();
await listAccounts();
6 replies
DDeno
Created by _Pear on 9/9/2023 in #help
KV list is returning an empty iterator, but data is there and gettable via get
sure !one moment
6 replies