Experiment of creating a TypeScript plugin (WIP)

This commit is contained in:
Jos de Jong 2023-03-13 16:04:11 +01:00
parent 946b4a495f
commit b9cfe706fc
5 changed files with 113 additions and 0 deletions

View 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
View 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
}