-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(component-store): effect handles generics that extend upon a type (…
- Loading branch information
1 parent
8219b1d
commit 9d2bda7
Showing
2 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { expecter } from 'ts-snippet'; | ||
import { compilerOptions } from './utils'; | ||
|
||
describe('regression component-store', () => { | ||
const expectSnippet = expecter( | ||
(code) => ` | ||
import { ComponentStore } from '@ngrx/component-store'; | ||
import { of, EMPTY, Observable } from 'rxjs'; | ||
import { concatMap } from 'rxjs/operators'; | ||
${code} | ||
`, | ||
compilerOptions() | ||
); | ||
|
||
it('https://github.com/ngrx/platform/issues/3482', () => { | ||
const effectTest = ` | ||
interface SomeType { | ||
name: string; | ||
prop: string; | ||
} | ||
export abstract class MyStore< | ||
QueryVariables extends SomeType | ||
> extends ComponentStore<any> { | ||
protected abstract readonly query$: Observable<Omit<QueryVariables, 'name'>>; | ||
readonly load = this.effect( | ||
(origin$: Observable<Omit<QueryVariables, 'name'> | null>) => origin$ | ||
); | ||
protected constructor() { | ||
super(); | ||
} | ||
protected initializeLoad() { | ||
// 👇 this should work | ||
this.load(this.query$); | ||
} | ||
} | ||
`; | ||
expectSnippet(effectTest).toSucceed(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters