View Issue Details

IDProjectCategoryView StatusLast Update
0005844Talerwallet-corepublic2022-12-05 09:09
ReporterFlorian Dold Assigned ToFlorian Dold  
PrioritylowSeveritytweakReproducibilityhave not tried
Status closedResolutionfixed 
Product Versiongit (master) 
Target Version0.9Fixed in Version0.9 
Summary0005844: use wrapper types instead of raw strings
DescriptionInstead of using e.g.

  contractHash: string

we should have wrapper types for everything. As TS doesn't support nominal typing (but only structural typing), we need to name the member of the wrapper structure according to its type. Thus the above becomes

  contractHash: HashCode

which is just an alias for

  contractHash: { sha512Hash: string }

To implement this without having to duplicate all structs, the JSON validator (checkable.ts) needs to support wrapping parsed JSON in these wrappers.
TagsNo tags attached.

Activities

Florian Dold

2020-09-08 18:12

manager   ~0016932

Instead of wrapper types, we can use flavors, which are compile-time only:

interface Flavoring<FlavorT> {
  _type?: FlavorT;
}
export type Flavor<T, FlavorT> = T & Flavoring<FlavorT>;

(via https://spin.atomicobject.com/2018/01/15/typescript-flexible-nominal-typing/)

This allows implicit conversions between the "unflavored" type and flavored type, but prevents mixups between different flavored types.

Issue History

Date Modified Username Field Change
2019-08-18 21:07 Florian Dold New Issue
2019-08-18 21:07 Florian Dold Status new => assigned
2019-08-18 21:07 Florian Dold Assigned To => Florian Dold
2020-09-04 12:16 Florian Dold Priority normal => low
2020-09-05 13:53 Christian Grothoff Severity minor => tweak
2020-09-08 18:12 Florian Dold Note Added: 0016932
2020-09-09 09:30 Florian Dold Category wallet (WebExtensions) => wallet (TS core)
2022-08-25 20:41 Christian Grothoff Status assigned => resolved
2022-08-25 20:41 Christian Grothoff Resolution open => fixed
2022-08-25 20:41 Christian Grothoff Fixed in Version => 0.9
2022-08-25 20:42 Christian Grothoff Product Version => git (master)
2022-08-25 20:42 Christian Grothoff Target Version => 0.9
2022-11-04 20:53 Christian Grothoff Status resolved => closed
2023-04-13 20:36 Florian Dold Category wallet (TS core) => wallet-core