Skip to content

Commit 769968f

Browse files
authored
lb4: fix usage of Context#get to specify type (#637)
1 parent 7ccfb55 commit 769968f

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

pages/en/lb4/Context.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ store along with the key. For example:
132132
// app level
133133
const app = new Application();
134134
app.bind('hello').to('world'); // ContextKey='hello', ContextValue='world'
135-
console.log(app.getSync('hello')); // => 'world'
135+
console.log(app.getSync<string>('hello')); // => 'world'
136136
```
137137

138138
In this case, we bind the 'world' string ContextValue to the 'hello' ContextKey.

pages/en/lb4/Decorators.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ Syntax: `@inject.tag(tag: string | RegExp)`.
290290
.bind('store.locations.sj')
291291
.to('San Jose')
292292
.tag('store:location');
293-
const store: Store = ctx.getSync('store');
293+
const store = ctx.getSync<Store>('store');
294294
// `store.locations` is now `['San Francisco', 'San Jose']`
295295
```
296296

@@ -305,7 +305,7 @@ Syntax: `@inject.context()`.
305305

306306
const ctx = new Context();
307307
ctx.bind('my-component').toClass(MyComponent);
308-
const component: MyComponent = ctx.getSync('my-component');
308+
const component = ctx.getSync<MyComponent>('my-component');
309309
// `component.ctx` should be the same as `ctx`
310310
```
311311

pages/en/lb4/Extending-LoopBack-4.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ ctx.bind('utilities.PasswordHash').to((password) => { /* ... */ })
6464
ctx.bind('controllers.UserController').toClass(UserController);
6565

6666
// Locate the an instance of UserController from the context
67-
const userController: UserController = await ctx.get('controller.UserController');
67+
const userController= await ctx.get<UserController>('controller.UserController');
6868
// Run the log()
6969
const ok = await logger.login('John', 'MyPassWord');
7070
```

0 commit comments

Comments
 (0)