TypeScript Conditional Types 条件类型在设计上是 distributable 的, 也就是可以按分配律,也可以不按分配律做处理,具体来说,只有在有泛型参数出现的情况下才会按 distributive 做处理,理由是底层实现如此:
而什么是分配律?其实跟乘法的分配律一样,是代数系统一种概念, 如:
type ABABC =Sometimes, debugging with console.log is not enough to find out what is
happening in the code, as console.log prints only plain objects but neither
functions nor objects with circular references. Besides, it's possible you
may need to know the context and flow of the code.
Read more about debugging with VS Code in VS Code: Debugging.
| { | |
| "version": "0.2.0", | |
| "configurations": [ | |
| { | |
| "name": "Example", | |
| "type": "node", | |
| "request": "launch", | |
| "runtimeExecutable": "node", | |
| "runtimeArgs": ["--nolazy", "-r", "ts-node/register/transpile-only"], |
| (function() { | |
| /** | |
| * 记录方法使用情况的类 | |
| * @param {Array.<boolean>} umMap 初始的使用情况 | |
| */ | |
| var UsageManager = function(umMap) { | |
| this.umMap = umMap || []; | |
| }; | |
| /** | |
| * 记录新的使用情况 |
| package main | |
| import ( | |
| "fmt" | |
| "reflect" | |
| ) | |
| func Decorate(impl interface{}) interface{} { | |
| fn := reflect.ValueOf(impl) |