@@ -8,12 +8,12 @@ import { Options, Result, ComponentInput } from './models';
8
8
@Component ( { selector : 'test-component' , template : '' } )
9
9
class TestComponent { }
10
10
11
- export async function createComponent ( template : string , options : Options ) : Promise < Result > ;
12
- export async function createComponent < T > ( component : ComponentInput < T > , options : Options ) : Promise < Result > ;
11
+ export async function createComponent < T > ( template : string , options : Options ) : Promise < Result < T > > ;
12
+ export async function createComponent < T > ( component : ComponentInput < T > , options : Options ) : Promise < Result < T > > ;
13
13
export async function createComponent < T > (
14
14
templateOrComponent : string | ComponentInput < T > ,
15
15
{ detectChanges = true , declarations = [ ] , providers = [ ] , imports = [ ] , schemas = [ ] } : Options ,
16
- ) : Promise < Result > {
16
+ ) : Promise < Result < T > > {
17
17
const isTemplate = typeof templateOrComponent === 'string' ;
18
18
const testComponent = isTemplate ? [ TestComponent ] : [ ] ;
19
19
@@ -39,12 +39,10 @@ export async function createComponent<T>(
39
39
fixture,
40
40
container : fixture . nativeElement ,
41
41
get : TestBed . get ,
42
- getComponentInstance : < C > ( selectorOrComponent : string | C ) =>
43
- typeof selectorOrComponent === 'string'
44
- ? fixture . debugElement . query ( By . css ( selectorOrComponent ) ) . componentInstance
45
- : fixture . componentInstance ,
46
- debug : ( ) => console . log ( prettyDOM ( fixture . nativeElement ) ) ,
42
+ getComponentInstance : < C = T > ( selector ?: string ) =>
43
+ selector ? fixture . debugElement . query ( By . css ( selector ) ) . componentInstance : fixture . componentInstance ,
47
44
detectChanges : ( checkNoChanges ?: boolean ) => fixture . detectChanges ( checkNoChanges ) ,
45
+ debug : ( ) => console . log ( prettyDOM ( fixture . nativeElement ) ) ,
48
46
...getQueriesForElement ( fixture . nativeElement ) ,
49
47
} ;
50
48
}
0 commit comments