Skip to content

Commit

Permalink
Rename identifiers
Browse files Browse the repository at this point in the history
Signed-off-by: Alexis Rico <sferadev@gmail.com>
  • Loading branch information
SferaDev committed Sep 26, 2024
1 parent 143598b commit 23c439b
Show file tree
Hide file tree
Showing 3 changed files with 205 additions and 205 deletions.
12 changes: 6 additions & 6 deletions packages/client/src/schema/identifiable.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test } from 'vitest';
import { NewIdentifiable } from './identifiable';
import { Identifiers } from './identifiable';

const tables = [

Check warning on line 4 in packages/client/src/schema/identifiable.spec.ts

View workflow job for this annotation

GitHub Actions / test

'tables' is assigned a value but only used as a type. Allowed unused vars must match /^_/u
{
Expand Down Expand Up @@ -53,7 +53,7 @@ const tables = [
] as const;

test('PrimaryKey', () => {
type Type = NewIdentifiable<typeof tables>['PrimaryKey'];
type Type = Identifiers<typeof tables>['PrimaryKey'];

const user: Type = { pk: 1 };

Check warning on line 58 in packages/client/src/schema/identifiable.spec.ts

View workflow job for this annotation

GitHub Actions / test

'user' is assigned a value but never used. Allowed unused vars must match /^_/u
const user1: Type = 1;

Check warning on line 59 in packages/client/src/schema/identifiable.spec.ts

View workflow job for this annotation

GitHub Actions / test

'user1' is assigned a value but never used. Allowed unused vars must match /^_/u
Expand All @@ -64,7 +64,7 @@ test('PrimaryKey', () => {
});

test('NullablePrimaryKey', () => {
type Type = NewIdentifiable<typeof tables>['NullablePrimaryKey'];
type Type = Identifiers<typeof tables>['NullablePrimaryKey'];

const user: Type = { pk: 1 };

Check warning on line 69 in packages/client/src/schema/identifiable.spec.ts

View workflow job for this annotation

GitHub Actions / test

'user' is assigned a value but never used. Allowed unused vars must match /^_/u
const user1: Type = 1;

Check warning on line 70 in packages/client/src/schema/identifiable.spec.ts

View workflow job for this annotation

GitHub Actions / test

'user1' is assigned a value but never used. Allowed unused vars must match /^_/u
Expand All @@ -75,7 +75,7 @@ test('NullablePrimaryKey', () => {
});

test('UniqueNotNull', () => {
type Type = NewIdentifiable<typeof tables>['UniqueNotNull'];
type Type = Identifiers<typeof tables>['UniqueNotNull'];

const user: Type = { foo: 'bar' };

Check warning on line 80 in packages/client/src/schema/identifiable.spec.ts

View workflow job for this annotation

GitHub Actions / test

'user' is assigned a value but never used. Allowed unused vars must match /^_/u
// @ts-expect-error
Expand All @@ -85,7 +85,7 @@ test('UniqueNotNull', () => {
});

test('CompositePrimaryKey', () => {
type Type = NewIdentifiable<typeof tables>['CompositePrimaryKey'];
type Type = Identifiers<typeof tables>['CompositePrimaryKey'];

const user: Type = { a: 1, b: '2' };
// @ts-expect-error
Expand All @@ -95,7 +95,7 @@ test('CompositePrimaryKey', () => {
});

test('Mixture', () => {
type Type = NewIdentifiable<typeof tables>['Mixture'];
type Type = Identifiers<typeof tables>['Mixture'];

const user: Type = { a: 1, b: '2', c: '3' };
// @ts-expect-error
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/schema/identifiable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { InputXataFile, NumericOperator } from './record';
*
* If neither found, never will be returned.
*/
export type NewIdentifiable<T extends readonly TableSchema[]> = T extends never[]
export type Identifiers<T extends readonly TableSchema[]> = T extends never[]
? never
: T extends readonly unknown[]
? T[number] extends { name: string; columns: readonly unknown[] }
Expand Down
Loading

0 comments on commit 23c439b

Please sign in to comment.