Skip to content

lb4: fix usage of Context#get to specify type #637

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pages/en/lb4/Context.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ store along with the key. For example:
// app level
const app = new Application();
app.bind('hello').to('world'); // ContextKey='hello', ContextValue='world'
console.log(app.getSync('hello')); // => 'world'
console.log(app.getSync<string>('hello')); // => 'world'
```

In this case, we bind the 'world' string ContextValue to the 'hello' ContextKey.
Expand Down
4 changes: 2 additions & 2 deletions pages/en/lb4/Decorators.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ Syntax: `@inject.tag(tag: string | RegExp)`.
.bind('store.locations.sj')
.to('San Jose')
.tag('store:location');
const store: Store = ctx.getSync('store');
const store = ctx.getSync<Store>('store');
// `store.locations` is now `['San Francisco', 'San Jose']`
```

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

const ctx = new Context();
ctx.bind('my-component').toClass(MyComponent);
const component: MyComponent = ctx.getSync('my-component');
const component = ctx.getSync<MyComponent>('my-component');
// `component.ctx` should be the same as `ctx`
```

Expand Down
2 changes: 1 addition & 1 deletion pages/en/lb4/Extending-LoopBack-4.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ ctx.bind('utilities.PasswordHash').to((password) => { /* ... */ })
ctx.bind('controllers.UserController').toClass(UserController);

// Locate the an instance of UserController from the context
const userController: UserController = await ctx.get('controller.UserController');
const userController= await ctx.get<UserController>('controller.UserController');
// Run the log()
const ok = await logger.login('John', 'MyPassWord');
```
Expand Down