Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: preserve function params type if possible (#14694)
* fix: preserve function params type if possible * chore: add test for default value
- Loading branch information
1 parent
a7c438c
commit 767c7b4
Showing
3 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
packages/babel-plugin-transform-parameters/test/fixtures/parameters/preserve-types/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
type Point = { | ||
x: number; | ||
y: number; | ||
}; | ||
|
||
function value({ x, y }: Point) { | ||
return x * y; | ||
} | ||
|
||
function valueWithDefault({ x, y }: Point = {}) { | ||
return x * y; | ||
} | ||
|
18 changes: 18 additions & 0 deletions
18
packages/babel-plugin-transform-parameters/test/fixtures/parameters/preserve-types/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
type Point = { | ||
x: number; | ||
y: number; | ||
}; | ||
|
||
function value(_ref: Point) { | ||
var x = _ref.x, | ||
y = _ref.y; | ||
return x * y; | ||
} | ||
|
||
function valueWithDefault() { | ||
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
x = _ref2.x, | ||
y = _ref2.y; | ||
|
||
return x * y; | ||
} |