Skip to content

Commit bea7a7d

Browse files
authored
[TS] Use 'override' when overriding class items (clockworklabs#3852)
# Description of Changes This should fix part of clockworklabs#3503. Adds an override modifier to generated code and fixes a warning from the angular compiler. # Expected complexity level and risk 1 # Testing - [x] Code works fine with the added `override` modifier. - [ ] Perhaps we should have an angular test project?
1 parent 111bc1a commit bea7a7d

12 files changed

Lines changed: 87 additions & 50 deletions

File tree

crates/bindings-typescript/examples/basic-react/src/module_bindings/index.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bindings-typescript/examples/empty/src/module_bindings/index.ts

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bindings-typescript/examples/quickstart-chat/src/module_bindings/index.ts

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bindings-typescript/src/lib/schema.ts

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -110,32 +110,21 @@ export function tablesToSchema<
110110
// UntypedTableDef expects mutable array; idxs are readonly, spread to copy.
111111
indexes: [
112112
...schema.idxs.map(
113-
(idx: Infer<typeof RawIndexDefV9>): IndexOpts<any> =>
114-
({
113+
(idx: Infer<typeof RawIndexDefV9>): IndexOpts<any> => {
114+
const columnIds =
115+
idx.algorithm.tag === 'Direct'
116+
? [idx.algorithm.value]
117+
: idx.algorithm.value;
118+
const columns = columnIds.map(i => colNameList[i]);
119+
return {
115120
name: idx.accessorName,
116-
unique: schema.tableDef.constraints
117-
.map(c => {
118-
if (idx.algorithm.tag == 'BTree') {
119-
return c.data.value.columns.every(col => {
120-
const idxColumns = idx.algorithm.value;
121-
if (Array.isArray(idxColumns)) {
122-
return idxColumns.includes(col);
123-
} else {
124-
return col === idxColumns;
125-
}
126-
});
127-
}
128-
})
129-
.includes(true),
121+
unique: schema.tableDef.constraints.some(c =>
122+
c.data.value.columns.every(col => columnIds.includes(col))
123+
),
130124
algorithm: idx.algorithm.tag.toLowerCase() as 'btree',
131-
columns: (() => {
132-
const cols =
133-
idx.algorithm.tag === 'Direct'
134-
? [idx.algorithm.value]
135-
: idx.algorithm.value;
136-
return cols.map(i => colNameList[i]);
137-
})(),
138-
}) as IndexOpts<any>
125+
columns,
126+
} as IndexOpts<any>;
127+
}
139128
),
140129
],
141130
} as const;

crates/bindings-typescript/src/sdk/client_api/index.ts

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bindings-typescript/test-app/src/module_bindings/index.ts

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bindings-typescript/test-react-router-app/src/module_bindings/counter_table.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bindings-typescript/test-react-router-app/src/module_bindings/index.ts

Lines changed: 57 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bindings-typescript/test-react-router-app/src/module_bindings/offline_user_table.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bindings-typescript/test-react-router-app/src/module_bindings/user_table.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)