Skip to content

Commit 9a277a4

Browse files
authored
Merge pull request #320 from hexlet-basics/update-type-assertions
update type checks
2 parents a18b91d + 75d6db5 commit 9a277a4

File tree

22 files changed

+65
-80
lines changed

22 files changed

+65
-80
lines changed
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import * as ta from 'type-assertions';
2-
import { expect, test } from 'vitest';
1+
import { expect, test, expectTypeOf } from 'vitest';
32

43
import multiply from './index';
54

65
test('multiply', () => {
76
expect(multiply(1, 3)).toBe(3);
87

9-
ta.assert<ta.Equal<ReturnType<typeof multiply>, number>>();
8+
expectTypeOf(multiply).returns.toMatchTypeOf<number>();
109
});
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import * as ta from 'type-assertions';
2-
import { expect, test } from 'vitest';
1+
import { expect, test, expectTypeOf } from 'vitest';
32

43
import repeat from './index';
54

@@ -8,5 +7,5 @@ test('repeat', () => {
87
expect(repeat('s', 2)).toBe('ss');
98
expect(repeat('s', 0)).toBe('');
109

11-
ta.assert<ta.Equal<ReturnType<typeof repeat>, string>>();
10+
expectTypeOf(repeat).returns.toMatchTypeOf<string>();
1211
});
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import * as ta from 'type-assertions';
2-
import { expect, test } from 'vitest';
1+
import { expect, test, expectTypeOf } from 'vitest';
32

43
import getHiddenCard from './index';
54

@@ -9,5 +8,5 @@ test('getHiddenCard', () => {
98
expect(getHiddenCard('1234123412344321', 2)).toEqual('**4321');
109
expect(getHiddenCard('1234123412341234', 12)).toEqual('************1234');
1110

12-
ta.assert<ta.Equal<ReturnType<typeof getHiddenCard>, string>>();
11+
expectTypeOf(getHiddenCard).returns.toMatchTypeOf<string>();
1312
});
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import * as ta from 'type-assertions';
2-
import { expect, test } from 'vitest';
1+
import { expect, test, expectTypeOf } from 'vitest';
32

43
import getEvenNumbers from './index';
54

65
test('function', () => {
76
expect(getEvenNumbers()).toEqual([8, 100, 34]);
87

9-
ta.assert<ta.Equal<ReturnType<typeof getEvenNumbers>, number[]>>();
8+
expectTypeOf(getEvenNumbers).returns.toMatchTypeOf<number[]>();
109
});

modules/10-basics/50-arrays/test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import * as ta from 'type-assertions';
2-
import { expect, test } from 'vitest';
1+
import { expect, test, expectTypeOf } from 'vitest';
32

43
import filterAnagrams from './index';
54

@@ -10,5 +9,5 @@ test('function', () => {
109

1110
expect(filterAnagrams('laser', ['lazing', 'lazy', 'lacer'])).toEqual([]);
1211

13-
ta.assert<ta.Equal<ReturnType<typeof filterAnagrams>, string[]>>();
12+
expectTypeOf(filterAnagrams).returns.toMatchTypeOf<string[]>();
1413
});

modules/10-basics/55-objects/test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import * as ta from 'type-assertions';
2-
import { expect, test } from 'vitest';
1+
import { expect, test, expectTypeOf } from 'vitest';
32

43
import isComplete from './index';
54

@@ -22,6 +21,6 @@ test('function', () => {
2221
};
2322
expect(isComplete(course3)).toBe(true);
2423

25-
ta.assert<ta.Equal<ReturnType<typeof isComplete>, boolean>>();
26-
ta.assert<ta.Equal<Parameters<typeof isComplete>[0], { name: string, lessons: string[] }>>();
24+
expectTypeOf(isComplete).returns.toMatchTypeOf<boolean>();
25+
expectTypeOf(isComplete).parameter(0).toMatchTypeOf<{ name: string, lessons: string[] }>();
2726
});

modules/10-basics/60-enums/test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import * as ta from 'type-assertions';
2-
import { expect, test } from 'vitest';
1+
import { expect, test, expectTypeOf } from 'vitest';
32

43
import buildModal, { ModalStatus } from './index';
54

@@ -10,5 +9,5 @@ test('function', () => {
109
expect(buildModal('code-basics', ModalStatus.Closed))
1110
.toEqual({ text: 'code-basics', status: ModalStatus.Closed });
1211

13-
ta.assert<ta.Equal<ReturnType<typeof buildModal>, { text: string, status: ModalStatus }>>();
12+
expectTypeOf(buildModal).returns.toMatchTypeOf<{ text: string, status: ModalStatus }>();
1413
});

modules/10-basics/70-type-aliases/test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import * as ta from 'type-assertions';
2-
import { expect, test } from 'vitest';
1+
import { expect, test, expectTypeOf } from 'vitest';
32

43
import getOlderUser, { User } from './index';
54

@@ -24,5 +23,5 @@ test('function', () => {
2423

2524
expect(getOlderUser(user2, user3)).toBeNull();
2625

27-
ta.assert<ta.Equal<ReturnType<typeof getOlderUser>, User | null>>();
26+
expectTypeOf(getOlderUser).returns.toMatchTypeOf<User | null>();
2827
});
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import * as ta from 'type-assertions';
2-
import { expect, test } from 'vitest';
1+
import { expect, test, expectTypeOf } from 'vitest';
32

43
import lastIndex from './index';
54

@@ -10,5 +9,5 @@ test('lastIndex', () => {
109
expect(lastIndex(str, 'e')).toBe(5);
1110
expect(lastIndex(str, 'p')).toBeNull();
1211

13-
ta.assert<ta.Equal<ReturnType<typeof lastIndex>, number | null>>();
12+
expectTypeOf(lastIndex).returns.toMatchTypeOf<number | null>();
1413
});

modules/25-types/25-literal-types/test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import * as ta from 'type-assertions';
2-
import { expect, test } from 'vitest';
1+
import { expect, test, expectTypeOf } from 'vitest';
32

43
import startGame from './index';
54

@@ -26,5 +25,5 @@ test('startTurtleGame', () => {
2625
makeTurn('left');
2726
expect(state).toEqual([null, null, null, 'turtle', null]);
2827

29-
ta.assert<ta.Equal<ReturnType<typeof makeTurn>, void>>();
28+
expectTypeOf(makeTurn).returns.toMatchTypeOf<void>();
3029
});

0 commit comments

Comments
 (0)