remove name argument from the reflect function
This commit is contained in:
parent
26631febf9
commit
7fc9d2a2f3
@ -1,10 +1,10 @@
|
||||
export function typed<T>(name: string, types: string, arg: T) : T {
|
||||
export function $reflect<T>(types: string, arg: T) : T {
|
||||
// TODO: implement typed-function for real
|
||||
if (types === '__infer__') {
|
||||
console.error('__infer__ should be replaced with runtime type information by the TypeScript plugin')
|
||||
}
|
||||
|
||||
console.log(`TYPED-FUNCTION: Creating function "${name}" with types ${types}`)
|
||||
console.log(`INFER: Creating function with types ${types}`)
|
||||
|
||||
// TODO: here we can now turn the inputs into a real typed-function with a signature
|
||||
return arg
|
@ -1,6 +1,6 @@
|
||||
import { typed } from '../core/typed.js'
|
||||
import { $reflect } from '../core/$reflect.js'
|
||||
|
||||
export const square = typed('square', '__infer__', <T>(dep: {
|
||||
export const square = $reflect('__infer__', <T>(dep: {
|
||||
multiply: (a: T, b: T) => T,
|
||||
unaryMinus: (x: T) => T, // just for the experiment
|
||||
}): (a: T) => T =>
|
||||
|
@ -13,13 +13,13 @@ const transformer: ts.TransformerFactory<ts.SourceFile> = context => {
|
||||
|
||||
// we're looking for a function call like typed('name', '__infer__', deps => ...)
|
||||
const parentNode = node.parent
|
||||
if (ts.isCallExpression(parentNode) && ts.isIdentifier(parentNode.expression) && parentNode.expression.escapedText === 'typed') {
|
||||
if (ts.isCallExpression(parentNode) && ts.isIdentifier(parentNode.expression) && parentNode.expression.escapedText === '$reflect') {
|
||||
// console.log('PARENT')
|
||||
// console.log(parentNode)
|
||||
|
||||
// TODO: validate that argNode is an ArrowFunction
|
||||
// @ts-ignore
|
||||
const argNode = parentNode.arguments[2]
|
||||
const argNode = parentNode.arguments[1]
|
||||
// @ts-ignore
|
||||
const returnType = argNode.type.getText(sourceFile)
|
||||
console.log('PLUGIN: RETURN TYPE')
|
||||
|
Loading…
Reference in New Issue
Block a user