vicary
vicary
Explore posts from servers
SSolidJS
Created by vicary on 8/1/2024 in #support
How to create and test a data fetching library?
Hello everyone, I am working on a SolidJS integration for GQty. PR#1758 is the current WIP, I am probably doing a lot of things wrong. There are two areas about Suspense where I would really love some help to learn from the perspective of a library author. 1. Triggering Suspense Having studied the source code of createResource, I am able to trigger an initial Suspense via createSignal by returning a Promise in my function. But Suspense doesn't happen again when I return a Promise during refetches. 2. Testing Suspense It seems that render() does not Suspense at all, instead it renders the Promise object as-is which in turn throws. What would be the best place to start?
55 replies
KKysely
Created by vicary on 6/7/2024 in #help
How to type tables with dynamic names?
The MS SQL dialect only supports global temporary objects, that forces us to add random table suffix to prevent collisions between sessions. Is it possible to type the table contents as a second query? Conceptually my code runs like this:
const tableName = `##TMP_${someRandomHash(6)}`;
const stream = await db
.connection()
.execute(async (con) => {
await sql`
SELECT colA, colB INTO ${sql.raw(tableName)}
FROM SomeTable;
`.execute(con);

return con.withTables<{
[tableName]: {
colA: string;
colB: string;
};
}>()
.selectFrom(tableName)
.select(["colA", "colB"])
.stream();
});

for await (const row of stream) {
// do stuff here
}
const tableName = `##TMP_${someRandomHash(6)}`;
const stream = await db
.connection()
.execute(async (con) => {
await sql`
SELECT colA, colB INTO ${sql.raw(tableName)}
FROM SomeTable;
`.execute(con);

return con.withTables<{
[tableName]: {
colA: string;
colB: string;
};
}>()
.selectFrom(tableName)
.select(["colA", "colB"])
.stream();
});

for await (const row of stream) {
// do stuff here
}
My current road blocks: 1. .withTables() does not accept object type with dynamic keys [tableName] where it shows this error A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type., 2. A raw SQL approach via sql literal does not provide a .stream() method.
6 replies
DDeno
Created by vicary on 3/11/2024 in #help
Is there a way to pull a module from x in favour of jsr?
I have ported my module @vicary/fresh-graphql to JSR and I would like to redirect my users go JSR instead of the unmaintained version in x. Is there a way to do that?
5 replies
DDeno
Created by vicary on 2/28/2024 in #help
Sorting tailwindcss class names with prettier plugin?
When developing in Fresh, I would like to have my class names automatically sorted with the official prettier plugin. How do I enable prettier plugins in a Deno project?
2 replies
DDeno
Created by vicary on 2/23/2024 in #help
Deno fmt with verbatimModuleSyntax?
Currently Deno fmt sorts verbatim imports alphabetically, this is conflicting with the Organize Imports in VS Code where it sorts import { type ... } entries individually at the end. Example:
// VS Code
import {
bar,
foo,
type Bar,
type Foo
} from "module";

// Deno fmt
import {
type Bar,
bar,
type Foo,
foo
} from "module";
// VS Code
import {
bar,
foo,
type Bar,
type Foo
} from "module";

// Deno fmt
import {
type Bar,
bar,
type Foo,
foo
} from "module";
When combined with the following VS Code option, all of the files flashes between the two formats in random order depending on how formatOnSave is configured.
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
}
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
}
Is it possible to add an option for Deno fmt, either disabling that part or expose an option to align with VS Code?
2 replies
DDeno
Created by vicary on 2/21/2024 in #help
NPM imports fail on JSON require
When importing modules via npm: protocol, the embedded esbuild will throw the following error if the module tries to require("package.json") .
Error: Build failed with 1 error:
../../../../../Library/Caches/deno/deno_esbuild/{module}@{version}/node_modules/{module}/package.json:2:8: ERROR: Expected ";" but found ":"
Error: Build failed with 1 error:
../../../../../Library/Caches/deno/deno_esbuild/{module}@{version}/node_modules/{module}/package.json:2:8: ERROR: Expected ";" but found ":"
In my case, the problematic module is checkout-sdk-node. Is there known workaround for this?
2 replies
KKysely
Created by vicary on 10/20/2023 in #help
How to improve performance in large SELECT?
I have a large query with >100 selections, this makes VS Code hangs for type checking every 30s. I tried $assertType() with a hard-coded object type at the end of the select query, but it doesn't help much. Is there a recommended way for large inferred types?
2 replies
KKysely
Created by vicary on 5/4/2023 in #help
How do Date columns works?
I am learning Kysely from the website, at the getting started section I can see the following line:
modified_at: ColumnType<Date, string | undefined, never>
modified_at: ColumnType<Date, string | undefined, never>
But ColumnType is type-only and should not affect runtime conversion, how does Kysely knows when to convert the data into Date in runtime?
10 replies