Skip to content

Instantly share code, notes, and snippets.

@chenyong
Created October 22, 2019 04:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chenyong/473b1f34302492adc2d73d81d180667f to your computer and use it in GitHub Desktop.
Save chenyong/473b1f34302492adc2d73d81d180667f to your computer and use it in GitHub Desktop.
Generation of router types(Drafted by hand)
/*
a
b
c/:cid
d/:did
e?f
g/:gid?h
*/
type RootOfGenRouterType = GenRouterTypes['a']['$types']
interface GenRouterTypes {
a: {
$types: {
name: 'a',
params: any,
queries: any,
next: GenRouterTypes['a']['b']['$type'] | GenRouterTypes['a']['c']['$type']
}
b: {
$type: {
name: 'b',
params: any,
queries: any,
next: any
}
}
c: {
$type: {
name: 'c',
params: {
cid: string
},
next: GenRouterTypes['a']['c']['d']['$type'] | GenRouterTypes['a']['c']['d']['$type'] | GenRouterTypes['a']['c']['g']['$type']
}
d: {
$type: {
name: 'd',
params: {
cid: string,
did: string
}
}
},
e: {
$type: {
name: 'e',
params: any,
queries: {
f: string
}
}
},
g: {
$type: {
name: 'g',
params: {
cid: string,
gid: string,
},
queries: {
h: string
},
next: any
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment