View Issue Details

IDProjectCategoryView StatusLast Update
0005844Talerwallet-corepublic2022-12-05 08:09
ReporterFlorian Dold Assigned ToFlorian Dold Resolution deadline
ImplementerReviewer 
Release signed byDeployed by 
VerifierCommunicator 
Data protection authority notification requiredNo  
CSIRT notification requiredNo  
Estimated effort (hours)Actual effort (hours)0 
Fast-trackNo
Work packagenone
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.

Required notifications

Address or linkRemarkAdded byNotifiedActions

Activities

Florian Dold

2020-09-08 16: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 ModifiedUsernameFieldChange
2019-08-18 19:07Florian DoldNew Issue
2019-08-18 19:07Florian DoldStatusnew => assigned
2019-08-18 19:07Florian DoldAssigned To => Florian Dold
2020-09-04 10:16Florian DoldPrioritynormal => low
2020-09-05 11:53Christian GrothoffSeverityminor => tweak
2020-09-08 16:12Florian DoldNote Added: 0016932
2020-09-09 07:30Florian DoldCategorywallet (WebExtensions) => wallet (TS core)
2022-08-25 18:41Christian GrothoffStatusassigned => informing
2022-08-25 18:41Christian GrothoffResolutionopen => fixed
2022-08-25 18:41Christian GrothoffFixed in Version => 0.9
2022-08-25 18:42Christian GrothoffProduct Version => git (master)
2022-08-25 18:42Christian GrothoffTarget Version => 0.9
2022-11-04 19:53Christian GrothoffStatusinforming => closed
2023-04-13 18:36Florian DoldCategorywallet (TS core) => wallet-core