Skip to content

Commit 2478eba

Browse files
committed
test: add typing test for ExtractTransformerVariants
1 parent dfc28d0 commit 2478eba

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tests/types.spec.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ import { PostTransformer } from './fixtures/transformers/post.ts'
1919
import { UserTransformer } from './fixtures/transformers/user.ts'
2020
import { EmailTransformer } from './fixtures/transformers/email.ts'
2121
import { ProfileTransformer } from './fixtures/transformers/profile.ts'
22-
import { type InferVariants, type InferData, type ResourceData } from '../src/types.ts'
22+
import {
23+
type InferVariants,
24+
type InferData,
25+
type ResourceData,
26+
type ExtractTransformerVariants,
27+
} from '../src/types.ts'
2328

2429
declare module '../src/types.ts' {
2530
interface ExtendedJSONTypes {
@@ -435,6 +440,12 @@ test.group('Types | Fixtures', () => {
435440
expectTypeOf(emailDataObject).toEqualTypeOf<EmailData>()
436441
})
437442

443+
test('make useVariant type-safe', async ({ expectTypeOf }) => {
444+
expectTypeOf<ExtractTransformerVariants<UserTransformer>>().toEqualTypeOf<
445+
'basicInfo' | 'toObject'
446+
>()
447+
})
448+
438449
test('infer all variants of a transformer', async ({ expectTypeOf }) => {
439450
const user = new User()
440451
const userTransformer = new UserTransformer(user)

0 commit comments

Comments
 (0)