Experiment of creating a TypeScript plugin (WIP)
This commit is contained in:
parent
946b4a495f
commit
b9cfe706fc
5 changed files with 113 additions and 0 deletions
8
src/generic/arithmeticDirect.ts
Normal file
8
src/generic/arithmeticDirect.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
import {infer} from './infer'
|
||||
|
||||
export const square = infer(<T>(dep: {
|
||||
multiply: (a: number, b: number) => number,
|
||||
unaryMinus: (x: number) => number, // just for the experiment
|
||||
}): (a: number) => number =>
|
||||
z => dep.multiply(z, z)
|
||||
)
|
4
src/generic/infer.ts
Normal file
4
src/generic/infer.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
export function infer<T>(arg: T) : T {
|
||||
console.error('infer should be replace with runtime type information by a magic TypeScript plugin')
|
||||
return arg
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue