After #31704 it would be useful to specify what is `Context.State` and
`Context` inside the `Router`'s handlers. For that, we could provide
a way to parameterize `Router` (also fallbacking to default `any` and
`{}` in case the generic type params are omitted).
So it would work like that:
```ts
type MyState = {foo: string}
type MyContext = {bar: string}
const app = new Koa<{}, {}>();
const router = new Router<MyState, MyContext>();
router.get('/', (ctx, next) => {
// ctx here is Koa.ParameterizedContext<MyState, MyContext & IRouterContext<MyState, MyContext>>
console.log(ctx.state.foo);
ctx.body = 'Hello World!';
});
app.use<MyState, MyContext>(async (ctx, next) => {
ctx.state.foo = "foo"
ctx.bar = "bar";
await next();
})
.use(router.routes())
.use(router.allowedMethods())
.use(async (ctx, next) => {
// ctx here is Koa.ParameterizedContext<MyState, MyContext & IRouterContext<MyState, MyContext>>
console.log(ctx.router);
console.log(ctx.bar);
await next();
})
.listen(3000);
```
But if we don't parameterize `Router`, it will work as before:
```ts
const app = new Koa();
const router = new Router();
router.get('/', (ctx, next) => {
// ctx here is Koa.ParameterizedContext<any, IRouterContext>
ctx.body = 'Hello World!';
});
app.use(async (ctx, next) => {
ctx.state.foo = "foo"
ctx.bar = "bar";
await next();
})
.use(router.routes())
.use(router.allowedMethods())
.listen(3000);
```
What do you think?
* [expo] Add types for SecureStore constants
* add use of keychainService; improve options types for getItemAsync and deleteItemAsync; test all SecureStore constants
In the react-intl source the prop is defined as follows:
tagName: PropTypes.oneOfType([PropTypes.string, PropTypes.element])
But it's actually passed straight to React.createElement(tagName, …),
so any type that is accepted by createElement should be allowed here.
It is useful to allow passing custom components to FormattedMessage,
for example when you use styled components, eg.
const FancyHeading = styled('h1')`font-size: 32px`;
<FormattedMessage … tagName={FancyHeading} />
Export the `BaseLine` interface to fix TS `cannot be named errors`, for example:
```bash
Exported variable 'scale' has or is using name 'BaseLine' from external module "node_modules/@types/typography/index" but cannot be named.ts(4023)
```
This commit includes ensuring methods exposed by the Set API is typed in a
consistent manner as per documentation:
* `.attr()` always returns `Snap.set`
* `.getBBox()`, `.insertAfter()` is added