Skip to content

Return type of public function is marked as internal #27

@meskill

Description

@meskill

Bug report

When I do not specify return type to public functions the returning literal object is transformed to the object with internal properties.

Input code

function fn(input: { test1: number; test2: string }): { a: number; b: string } {
  return {
    a: 2,
    b: 'str',
  };
}

export function fn2(input: { test1: number; test2: string }) {
  const { a } = fn({ test1: 25, test2: 'test' });

  return {
    a,
    b: 'str',
  };
}

Expected output

function fn(input) {
    return {
        _internal_a: 2,
        _internal_b: 'str',
    };
}
function fn2(input) {
    const { _internal_a: a } = fn();
    return {
        a,
        b: 'str',
    };
}

export { fn2 };

Actual output

function fn(input) {
    return {
        _internal_a: 2,
        _internal_b: 'str',
    };
}
function fn2(input) {
    const { _internal_a: a } = fn();
    return {
        _internal_a: a,
        _internal_b: 'str',
    };
}

export { fn2 };

Additional context
If I specify return type explicitly it works as expected

function fn(input: { test1: number; test2: string }): { a: number; b: string } {
  return {
    a: 2,
    b: 'str',
  };
}

export function fn2(input: { test1: number; test2: string }): { a: number; b: string } { // this is the only change as return type is explicit now
  const { a } = fn({ test1: 25, test2: 'test' });

  return {
    a,
    b: 'str',
  };
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions