Suggestion: Units of measure
This feature request is similar to [units of measure in F#](http://msdn.microsoft.com/en-us/library/dd233243.aspx). For example: ``` typescript const metres = 125<m>; const seconds = 2<s>; let speed: number<m/s>; speed = metres / seconds; // valid speed = metres / seconds / 10<s>; // error -- cannot convert m/s**2 to m/s ``` (Moved from [work item 1715 on Codeplex](https://typescript.codeplex.com/workitem/1715).) # Proposal **Last Updated:** 2016-06-09 **Copied from:** https://github.com/dsherret/Units-of-Measure-Proposal-for-TypeScript --- ## Overview Units of measure is a useful [F# feature](http://msdn.microsoft.com/en-us/library/dd233243.aspx) that provides the optional ability to create tighter constraints on numbers. TypeScript could benefit from a similar feature that would add **zero runtime overhead**, increase type constraints, and help decrease programmer error when doing mathematical calculations that involve units. The feature should prefer explicity. ## Defining Units of Measure Units of measure should probably use syntax similar to type aliases (#957). More discussion is needed on this, but for the purpose of this document it will use the following syntax: ``` typescript type measure <name> [ = measure expression ]; ``` The optional measure expression part can be used to define a new measures in terms of previously defined measures. ### Example Definitions ``` typescript type measure m; type measure s; type measure a = m / s**2; ``` Uni
Posted by dsherret on Aug 5, 2014, 9:26 PM
Tags
Related issues
- [Meta] Feedback on granular control over Copilot changes
- unexpected status 401 Unauthorized issue
- [MODEL] Measurable quality regression in Claude generation 5 (Fable 5 / Opus 5 / Sonnet 5): worse nonsense detection, ~2x verbosity, under-disclosed model fallb
- [CRITICAL] Subagent spawning and subagent pattern bugs trigger infinite recursion, infinite token usage, grossly inefficient token usage, and lost accumulated s
- Video stops playing after some minutes
- [MODEL] Claude verbose code comments by default — ignores instructions to stop.
Raise real-world problems, find people facing the same issue, and discuss solutions.9,000 issues0 comments
github (Software)
[Meta] Feedback on granular control over Copilot changes
unexpected status 401 Unauthorized issue
[MODEL] Measurable quality regression in Claude generation 5 (Fable 5 / Opus 5 / Sonnet 5): worse nonsense detection, ~2x verbosity, under-disclosed model fallb
[CRITICAL] Subagent spawning and subagent pattern bugs trigger infinite recursion, infinite token usage, grossly inefficient token usage, and lost accumulated s
Video stops playing after some minutes
[MODEL] Claude verbose code comments by default — ignores instructions to stop.
Scope Codex VS Code chats to the current workspace/project
Update on "Co-authored-by: Copilot" in commit messages
Suggestion: Units of measure
This feature request is similar to [units of measure in F#](http://msdn.microsoft.com/en-us/library/dd233243.aspx). For example: ``` typescript const metres = 125<m>; const seconds = 2<s>; let speed: number<m/s>; speed = metres / seconds; // valid speed = metres / seconds / 10<s>; // error -- cannot convert m/s**2 to m/s ``` (Moved from [work item 1715 on Codeplex](https://typescript.codeplex.com/workitem/1715).) # Proposal **Last Updated:** 2016-06-09 **Copied from:** https://github.com/dsherret/Units-of-Measure-Proposal-for-TypeScript --- ## Overview Units of measure is a useful [F# feature](http://msdn.microsoft.com/en-us/library/dd233243.aspx) that provides the optional ability to create tighter constraints on numbers. TypeScript could benefit from a similar feature that would add **zero runtime overhead**, increase type constraints, and help decrease programmer error when doing mathematical calculations that involve units. The feature should prefer explicity. ## Defining Units of Measure Units of measure should probably use syntax similar to type aliases (#957). More discussion is needed on this, but for the purpose of this document it will use the following syntax: ``` typescript type measure <name> [ = measure expression ]; ``` The optional measure expression part can be used to define a new measures in terms of previously defined measures. ### Example Definitions ``` typescript type measure m; type measure s; type measure a = m / s**2; ``` Uni
Comments (0)
No comments yet. Start the discussion.