File tree 2 files changed +46
-0
lines changed
Filter options
2 files changed +46
-0
lines changed
Original file line number Diff line number Diff line change
1
+ import { expect , it } from "vitest" ;
2
+ import { Equal , Expect } from "./helpers/type-utils" ;
3
+
4
+ const guitarists = new Set ( ) ;
5
+
6
+ guitarists . add ( "Jimi Hendrix" ) ;
7
+ guitarists . add ( "Eric Clapton" ) ;
8
+
9
+ it ( "Should contain Jimi and Eric" , ( ) => {
10
+ expect ( guitarists . has ( "Jimi Hendrix" ) ) . toEqual ( true ) ;
11
+ expect ( guitarists . has ( "Eric Clapton" ) ) . toEqual ( true ) ;
12
+ } ) ;
13
+
14
+ it ( "Should give a type error when you try to pass a non-string" , ( ) => {
15
+ // @ts -expect-error
16
+ guitarists . add ( 2 ) ;
17
+ } ) ;
18
+
19
+ it ( "Should be typed as an array of strings" , ( ) => {
20
+ const guitaristsAsArray = Array . from ( guitarists ) ;
21
+
22
+ type cases = [ Expect < Equal < typeof guitaristsAsArray , string [ ] > > ] ;
23
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import { expect , it } from "vitest" ;
2
+ import { Equal , Expect } from "./helpers/type-utils" ;
3
+
4
+ const guitarists = new Set < string > ( ) ;
5
+
6
+ guitarists . add ( "Jimi Hendrix" ) ;
7
+ guitarists . add ( "Eric Clapton" ) ;
8
+
9
+ it ( "Should contain Jimi and Eric" , ( ) => {
10
+ expect ( guitarists . has ( "Jimi Hendrix" ) ) . toEqual ( true ) ;
11
+ expect ( guitarists . has ( "Eric Clapton" ) ) . toEqual ( true ) ;
12
+ } ) ;
13
+
14
+ it ( "Should give a type error when you try to pass a non-string" , ( ) => {
15
+ // @ts -expect-error
16
+ guitarists . add ( 2 ) ;
17
+ } ) ;
18
+
19
+ it ( "Should be typed as an array of strings" , ( ) => {
20
+ const guitaristsAsArray = Array . from ( guitarists ) ;
21
+
22
+ type cases = [ Expect < Equal < typeof guitaristsAsArray , string [ ] > > ] ;
23
+ } ) ;
You can’t perform that action at this time.
0 commit comments