Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions crates/codegen/src/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -759,16 +759,23 @@ impl Lang for TypeScript {
);

writeln!(out);
if has_table_accessor_aliases {
// Narrow `db` by merging an interface into the class rather than with a
// `declare` field, which Babel (React Native, Expo) rejects by default.
writeln!(out, "export interface DbConnection {{");
out.indent(1);
writeln!(out, "db: DbView;");
out.dedent(1);
writeln!(out, "}}");
writeln!(out);
}
writeln!(out, "/** The typed database connection to manage connections to the remote SpacetimeDB instance. This class has type information specific to the generated module. */");
writeln!(
out,
"export class DbConnection extends __DbConnectionImpl<typeof REMOTE_MODULE> {{"
);
out.indent(1);
if has_table_accessor_aliases {
writeln!(out, "declare db: DbView;");

writeln!(out);
writeln!(
out,
"constructor(config: __DbConnectionConfig<typeof REMOTE_MODULE>) {{"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,12 @@ export class SubscriptionBuilder extends __SubscriptionBuilderImpl<typeof REMOTE
/** Builder class to configure a new database connection to the remote SpacetimeDB instance. */
export class DbConnectionBuilder extends __DbConnectionBuilder<DbConnection> {}

export interface DbConnection {
db: DbView;
}

/** The typed database connection to manage connections to the remote SpacetimeDB instance. This class has type information specific to the generated module. */
export class DbConnection extends __DbConnectionImpl<typeof REMOTE_MODULE> {
declare db: DbView;

constructor(config: __DbConnectionConfig<typeof REMOTE_MODULE>) {
super(config);
this.db = __withTableAccessorAliases(this.db) as DbView;
Expand Down
6 changes: 4 additions & 2 deletions demo/Blackholio/client-ts/src/module_bindings/index.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions templates/hangman-react-ts/src/module_bindings/index.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading