-
-
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.
feat(store): compile time errors when action creators being passed to…
… dispatch without () (#2306)
- Loading branch information
1 parent
de703f0
commit 98b74ad
Showing
3 changed files
with
34 additions
and
2 deletions.
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,22 @@ | ||
import { expecter } from 'ts-snippet'; | ||
import { compilerOptions } from './utils'; | ||
|
||
describe('Store', () => { | ||
const expectSnippet = expecter( | ||
code => ` | ||
import { Store, createAction } '@ngrx/store'; | ||
const store = {} as Store<{}>; | ||
const fooAction = createAction('foo') | ||
${code} | ||
`, | ||
compilerOptions() | ||
); | ||
|
||
it('should not allow passing action creator function without calling it', () => { | ||
expectSnippet(`store.dispatch(fooAction);`).toFail( | ||
/is not assignable to type '"Functions are not allowed to be dispatched. Did you forget to call action creator function/ | ||
); | ||
}); | ||
}); |
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
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