Skip to content

Commit

Permalink
docs: add missing return to example storage.service.ts (#31434)
Browse files Browse the repository at this point in the history
While JavaScript does support implicit returns, it seems TypeScript will not infer the function return type from
the implicit return of the last statement (at least not in TS 3.4.3). So, when the `return` is missing from the
`get` function the implicit type of the function is `void`. So for the `get` function to be usable it needs to an
explicit return.

PR Close #31434
  • Loading branch information
jfoshee authored and AndrewKushnir committed Nov 20, 2020
1 parent 2b2d572 commit babbf8a
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -16,7 +16,7 @@ export class BrowserStorageService {
constructor(@Inject(BROWSER_STORAGE) public storage: Storage) {}

get(key: string) {
this.storage.getItem(key);
return this.storage.getItem(key);
}

set(key: string, value: string) {
Expand Down

0 comments on commit babbf8a

Please sign in to comment.