Skip to content

Commit

Permalink
enhance Typescript comment
Browse files Browse the repository at this point in the history
  • Loading branch information
tja4472 committed Feb 24, 2019
1 parent 10412bc commit ca6d9db
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions modules/store/src/action_creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,15 @@ export function createAction<
[key: string]: any;
}
>(type: T, payload?: P) {
// Spread types may only be created from object types. ts(2698) Typescript 3.1.1
// const action = payload === undefined ? { type } : { type, ...payload };
/*
The following line requires Typescript 3.2: Generic spread expressions in
object literals.
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-2.html
Typescript 3.1.1 gives error: Spread types may only be created from
object types. ts(2698)
*/
// const action = payload === undefined ?{ type } : { type, ...payload };
const action =
payload === undefined ? { type } : { type, ...(payload as object) };
return action;
Expand Down

0 comments on commit ca6d9db

Please sign in to comment.