Repository navigation
Added extracting of templated params from params - #35
Conversation
| "scripts": { | ||
| "unit": "tsm node_modules/uvu/bin.js . '\\.test\\.(ts|js)$'", | ||
| "test": "c8 yarn unit && eslint . && check-dts && size-limit", | ||
| "test": "c8 yarn unit && eslint . --report-unused-disable-directives && check-dts && size-limit", |
There was a problem hiding this comment.
This change should be in different PR
| * @param input Template string. | ||
| * @return Transform for translation. | ||
| */ | ||
| <Input extends string>(input: Input): TranslationFunction< |
There was a problem hiding this comment.
In Router we were forced to define argument as const to be sure that TS will use "/posts/:id" type instead of just string https://github.com/nanostores/router/blob/main/index.d.ts#L132C30-L132C35
Why we don’t need it here?
There was a problem hiding this comment.
Bcs in router types it's needed to narrow types for the other consumers, that will be working with returned type. Here I don't see cases why it might be necessary, but I might be wrong)
There was a problem hiding this comment.
I was passing by and wanted to give a hint that using canonical URLs will be safer in the future. Just press y and the URL will become this: https://github.com/nanostores/router/blob/e927e23d509d1cde4140653071743a3c370de70b/index.d.ts#L132C30-L132C35
|
|
||
| interface Params { | ||
| /** | ||
| * Add `{name}` parameters to translation strings. |
There was a problem hiding this comment.
We will need also to change docs in TypeDoc example and in README.md
|
@ai wdyt about adding a case with |
|
Thanks. Released at 0.11. |
Close #34
Hi! This pull request solves the problem of autoinferring parameters for the
paramsfunction, but with two edge cases:countfunction, is not processed here. This requires an extension of the return type signature of theTranslationFunctionfunction (even if it will be readable), and will likely require updating the types of all utilities.