Skip to content

Commit

Permalink
Don't check type annotations when deciding params scope (#11349)
Browse files Browse the repository at this point in the history
* Don't check type annotations when deciding params scope

* Also type params
  • Loading branch information
nicolo-ribaudo committed Apr 5, 2020
1 parent aeebc08 commit 65d09e4
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/babel-plugin-transform-parameters/src/params.js
Expand Up @@ -36,6 +36,9 @@ const iifeVisitor = {
path.stop();
}
},
// type annotations don't use or introduce "real" bindings
"TypeAnnotation|TSTypeAnnotation|TypeParameterDeclaration|TSTypeParameterDeclaration": path =>
path.skip(),
};

export default function convertFunctionParams(path, loose) {
Expand Down
@@ -0,0 +1,7 @@
function a(b: (c) => void = {}) {
let c;
}

function d(e = <T>() => {}) {
let T;
}
@@ -0,0 +1,6 @@
{
"plugins": [
"transform-parameters",
"syntax-flow"
]
}
@@ -0,0 +1,9 @@
function a() {
let b: (c) => void = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
let c;
}

function d() {
let e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : <T>() => {};
let T;
}
@@ -0,0 +1,7 @@
function a(b: (c) => void = {}) {
let c;
}

function d(e = <T>() => {}) {
let T;
}
@@ -0,0 +1,6 @@
{
"plugins": [
"transform-parameters",
"syntax-typescript"
]
}
@@ -0,0 +1,9 @@
function a() {
let b: (c) => void = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
let c;
}

function d() {
let e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : <T>() => {};
let T;
}

0 comments on commit 65d09e4

Please sign in to comment.