fix(types): `MergeSchemaPath` supports regexp path params (#2271)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
* fix(types): `MergeSchemaPath` supports regexp path params * denoify
authored by Yusuke Wada · committed by GitHub · parent 4b3cd3c · Browse files · 3 files·+55 added−4 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+55 added−4 removed
- tests:+19 added−0 removed
- other:+36 added−4 removed
Provenance
- Commit
1c4c395- Tree
1f19eb1- Author
Yusuke Wada <yusuke@kamawada.com>- Committer
GitHub <noreply@github.com>- Parent
4b3cd3c
3 files changed+55 added−4 removed
modified:deno_dist/types.ts+18 added-2 removed
1613 unmodified lines1614 ? {1615 input: Input extends { param: infer _ }1616 ? ExtractParams<SubPath> extends never1617 ? Input1618- : FlattenIfIntersect<Input & { param: ExtractParams<SubPath> }>1618+ : FlattenIfIntersect<1619+ Input & {1620+ param: {1621+ // Maps extracted keys, stripping braces, to a string-typed record.1622+ [K in keyof ExtractParams<SubPath> as K extends `${infer Prefix}{${infer _}}`1623+ ? Prefix1624+ : K]: string1625+ }1626+ }1627+ >1628 : RemoveBlankRecord<ExtractParams<SubPath>> extends never1629 ? Input1621- : Input & { param: ExtractParams<SubPath> }1630+ : Input & {1631+ // Maps extracted keys, stripping braces, to a string-typed record.1632+ param: {1633+ [K in keyof ExtractParams<SubPath> as K extends `${infer Prefix}{${infer _}}`1634+ ? Prefix1635+ : K]: string1636+ }1637+ }1638 output: Output1639 }1640 : never1641 }130 unmodified linesmodified:src/types.test.ts+19 added
679 unmodified lines680 }681 }682 type verify = Expect<Equal<Expected, Actual>>683 })684+685+ test('MergeSchemaPath - Path and SubPath have regexp path params', () => {686+ type Actual = MergeSchemaPath<ToSchema<'get', '/c/:d{.+}', {}, {}>, '/a/:b{.+}'>687+ type Expected = {688+ '/a/:b{.+}/c/:d{.+}': {689+ $get: {690+ input: {691+ param: {692+ d: string693+ } & {694+ b: string695+ }696+ }697+ output: {}698+ }699+ }700+ }701+ type verify = Expect<Equal<Expected, Actual>>702+ })703 })704 705 describe('Different types using json()', () => {706 describe('no path pattern', () => {748 unmodified linesmodified:src/types.ts+18 added-2 removed
1613 unmodified lines1614 ? {1615 input: Input extends { param: infer _ }1616 ? ExtractParams<SubPath> extends never1617 ? Input1618- : FlattenIfIntersect<Input & { param: ExtractParams<SubPath> }>1618+ : FlattenIfIntersect<1619+ Input & {1620+ param: {1621+ // Maps extracted keys, stripping braces, to a string-typed record.1622+ [K in keyof ExtractParams<SubPath> as K extends `${infer Prefix}{${infer _}}`1623+ ? Prefix1624+ : K]: string1625+ }1626+ }1627+ >1628 : RemoveBlankRecord<ExtractParams<SubPath>> extends never1629 ? Input1621- : Input & { param: ExtractParams<SubPath> }1630+ : Input & {1631+ // Maps extracted keys, stripping braces, to a string-typed record.1632+ param: {1633+ [K in keyof ExtractParams<SubPath> as K extends `${infer Prefix}{${infer _}}`1634+ ? Prefix1635+ : K]: string1636+ }1637+ }1638 output: Output1639 }1640 : never1641 }130 unmodified lines