Skip to content

Function arguments desctructuring #4548

Closed
@NekR

Description

@NekR

This does not work. This is expected since I have "noImplicitAny": true:

function test({ x, y }) {
  console.log(x, y);
}

test({
  x: 1,
  y: 2
});

src\main.ts(15,17): error TS7005: Variable 'x' implicitly has an 'any' type.
src\main.ts(15,20): error TS7005: Variable 'y' implicitly has an 'any' type.

However, function test({ x:number, y:number }) { does not works too, while function test({ x = 0, y = 0 }) { works fine, but I do not want default params here. Is there a solution for it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions