File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change 2
2
// types and interfaces
3
3
// ----------------------------------------------------------------------------
4
4
5
- export type DoubledObject < Subject > = Subject ;
5
+ export type DoubledObject < T > = T ;
6
6
7
- export type DoubledObjectWithKey < Key extends string > = { } ;
7
+ export type DoubledObjectWithKey < T extends string > = { [ K in T ] } ;
8
8
9
- export type TestDouble < Function > = Function ;
9
+ export type TestDouble < T > = T ;
10
10
11
11
export type TestDoubleConstructor < T > = Constructor < T > ;
12
12
@@ -156,7 +156,7 @@ export function object<T>(constructor: Constructor<T> ): DoubledObject<T>;
156
156
* @param {Key[] } props Array of properties.
157
157
* @returns {DoubledObjectWithKey<Key> }
158
158
*/
159
- export function object < Key extends string > ( props : Key [ ] ) : DoubledObjectWithKey < Key > ;
159
+ export function object < T extends string > ( props : T [ ] ) : DoubledObjectWithKey < T > ;
160
160
161
161
/**
162
162
* Create a fake empty object that is cast as the generic using a Proxy object.
Original file line number Diff line number Diff line change @@ -43,6 +43,10 @@ td.when(dog.bark()).thenReturn("bark!");
43
43
44
44
// td.object()
45
45
46
+ const cat = td . object ( [ "scratch" , "meow" ] ) ;
47
+ td . when ( cat . scratch ( ) ) . thenReturn ( "scratch!" ) ;
48
+ td . when ( cat . meow ( ) ) . thenReturn ( "meow!" ) ;
49
+
46
50
const bird = td . object ( { fly : function ( ) { } } ) ;
47
51
td . when ( bird . fly ( ) ) . thenReturn ( "fly!" ) ;
48
52
You can’t perform that action at this time.
0 commit comments