【发布时间】:2016-07-06 17:22:45
【问题描述】:
我的问题是打字稿中是否存在运算符重载,如果存在,我可以给出一个示例或链接,您可以在其中阅读它。
【问题讨论】:
标签: typescript operator-overloading
我的问题是打字稿中是否存在运算符重载,如果存在,我可以给出一个示例或链接,您可以在其中阅读它。
【问题讨论】:
标签: typescript operator-overloading
不,它不存在。除非有关于如何在纯 JavaScript 中实现的明确规范,否则它不太可能存在。
【讨论】:
Couldn't the TypeScript compiler, for example, convert a + operator in the TypeScript source with a function call in the JavaScript output 它可以 但这会破坏 TypeScript 的全部意义 Add or rely on run-time type information in programs, or emit different code based on the results of the type system. Instead, encourage programming patterns that do not require run-time metadata. github.com/Microsoft/TypeScript/wiki/…