Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign updevelopment guide of TypeScript #630
Open
Labels
Comments
|
I am now using simple interfaces. export type WithGroupProps<OwnMatchProps = {}> = {
match?: { groups?: Partial<OwnMatchProps> }
}
export type LineAction<OwnProps = {}> = (
context: LineContext,
props: Props<Client, LineEvent> & OwnProps,
) => Promise<Action<Client, LineEvent> | undefined | void>
// it can return props.next
expectType<LineAction>(async (context, props) => {
console.assert(context.sendFlex.call)
return props.next
})
// it can have OwnProps
expectType<
LineAction<{
ownProp1: { nestProp1: string }
ownProp2: { nestProp2: string }
}>
>(async (context, props) => {
console.assert(props.ownProp1.nestProp1)
console.assert(props.ownProp2.nestProp2)
})
// it can use with WithGroupProps
expectType<
LineAction<
{
ownProp1: { nestProp1: string }
ownProp2: { nestProp2: string }
} & WithGroupProps<{
command: string
}>
>
>(async (context, props) => {
console.assert(props.match?.groups?.command)
console.assert(props.ownProp1.nestProp1)
console.assert(props.ownProp2.nestProp2)
})FYI thanks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment


Hi, I just looking for a development guide for TypeScript.
Or maybe just an interface
LineClientorLineActiongot export is enough for me.The reason is bottender now got have interfaces of Action, Client, Event and Props etc. It's wonderful.
With these interfaces, I can say
const SayHi: Action<Client, Event>, which with argument interfacescontext.sendTextandprops?.nextand etc.But the problem is
Action<Client, Event>interface has nocontext.sendFlex, and seemsLineClienthas no export by bottender. Therefore I can not tell VSCodeAction<LineClient, LineEvent>.Currently, my workaround is
The workaround is working fine, but it will get the next problem on
import { text } from 'bottender'What do you think?