-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add client typecheck, add test for Entity type
- Loading branch information
Showing
4 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { expectTypeOf, test } from 'vitest'; | ||
import { Schema as S } from '@triplit/db'; | ||
import { Entity } from '../../src/utils/query'; | ||
|
||
test('Entity', () => { | ||
const schema = { | ||
a: { | ||
schema: S.Schema({ | ||
id: S.Id(), | ||
attr: S.String(), | ||
rel: S.RelationById('b', '$bId'), | ||
}), | ||
}, | ||
b: { | ||
schema: S.Schema({ | ||
id: S.Id(), | ||
attr: S.String(), | ||
}), | ||
}, | ||
}; | ||
expectTypeOf<Entity<typeof schema, 'a'>>().toEqualTypeOf<{ | ||
id: string; | ||
attr: string; | ||
}>(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// TODO: combine with tsconfigs | ||
{ | ||
"compilerOptions": { | ||
"lib": ["ESNext"], | ||
"target": "ESNext", // You can adjust the target as needed. | ||
"module": "ESNext", // This will be overridden in npm scripts | ||
"moduleResolution": "node", | ||
"strict": true, | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
// "noUnusedLocals": true, | ||
// "noUnusedParameters": true, | ||
"noImplicitReturns": true, | ||
"skipLibCheck": true, | ||
"useDefineForClassFields": true | ||
}, | ||
"include": ["./test/**/*.test-d.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { defineConfig } from 'vitest/config'; | ||
|
||
export default defineConfig({ | ||
test: { | ||
typecheck: { | ||
ignoreSourceErrors: false, | ||
tsconfig: './tsconfig.test.json', | ||
}, | ||
}, | ||
}); |