Skip to content

[type-compiler] function __types should be hoisted? #664

@PedroClerici

Description

@PedroClerici

I was using @deepkit/type and found a problem with function hoisting reflections.

import { ReflectionFunction } from "@deepkit/type";

ReflectionFunction.from(system).getParameters(); // returns: []

function system(foo: string) {
    return foo
}

So I made a fork and tried to fix the issue. It kinda worked:

import { ReflectionFunction } from "@deepkit/type";

ReflectionFunction.from(system).getParameters(); // returns: [ ReflectionParameter { parameter: { kind ...

function system(foo: string) {
    return foo
}

But now, this is a issue:

import { ReflectionFunction } from "@deepkit/type";

console.log(ReflectionFunction.from(system).getParameters()); // ReferenceError: Cannot access '__ΩFoo' before initialization

class Bar {}

type Foo = Bar

function system(foo: Foo) {
    return foo
}

So should we hoist everything to make it work? or leave it be?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions