* add tests on regression 12386
* fix: update cache on _replaceWith
* fix: pathCache in replaceWithMultiple could be nullish
* Update packages/babel-traverse/src/path/replacement.js
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
* test: add replaceWith test to traverse
Co-authored-by: Brian Ng <bng412@gmail.com>
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
* Mark `ThisExpression` as `Purish`
The other purish types are functions and literals, so I
guess it means "it doesn't have side effects"
* Super & tests
* Fix tests
* ➕ add test fixture
* ➕ add removeTypeDuplicates for typescript
* ➕ add createTSUnionType for typescript
* 💊 fix ConditionalExpression for typescript
* 💊 fix ConditionalExpression
* 💊 fix added test case
* ➕ add new line at the end of the file
* 💊 types.every(f) => f(types[0])
* 🔄 bug => foo
* ➕ add TSBaseType
* ➕ add conditions NOT to break backward compatibility
* Bug replication test
* Simplify test
* Fixes#10896
* Merge path.crawl `ClassDeclaration` and `Declaration` visitors
Merged to avoid subtle assumption that `Declaration` is called before `ClassDeclaration`
* Move registartion of class id in crawl to BlockScoped
* Add some assertions to crawl test
* fix: parameter expression closure should not have access to the declaration inside function body
* fix: renameVisitor should skip when a pattern is a scope
* address review comments
* Don't use args rest/spread to hoist super method calls
* Hoist this in hoisted super method calls
* Make the code more readable
Review by edoardocavazza
* test case for insertBefore for jsx
* fix unshiftContainer and insertBefore
* use path.scope.push
* add test making sure computedKeys var declaration at the right block
* add comment
* nit [skip ci]
* @babel/traverse: Fix NodePath.getData
Currently, if the obtained value is `false`, it will be replaced by the given default value, which is invalid. This makes sure that we only set the default value when the value is `undefined`, instead of falsy.
* Add test and fix object protoype
* Allow false as default value
When traversing a tree parsing for TypeScript syntax and hitting a `TSFunctionType` node, the `typeParameters` and `typeAnnotation` fields are correctly visited but the `parameters` field isn't. As a result visitors by default don't visit `foo` below:
```
var x: (foo) => void; // foo is never visited
```
```
module.exports = function() {
return {
visitor: {
Identifier(path) {
if (path.node.name == "foo") {
// Never hit because it's nested within TSFunctionType.parameters
path.node.name = "bar";
}
}
}
};
}
```
It appears to be a bug in babel-types/src/definitions/typescript.js which omits `parameters` in the visitors list for `fnOrCtr`. Fixed by adding it.
* Migrate try-catch duplicate error
* Remove exception for functions and let in the same scope
* Migrate duplicate bindings tests to traverse
* Add test for subscope and let/const
* Add more test cases
* [decorators] Correctly insert `_initialize(this)` after `super()`.
This commit fixes to problem:
1) After `super();` statements, `_initialize(this)` was inserted without
a trailing semicolon.
2) `(0, super())` causes an infinite recursion.
* Fix tests
* Add test
These are now enabled by default:
- objectRestSpread (2018)
- asyncGenerators (2018)
- optionalCatchBInding (2019)
- jsonStrings (2019)
TODO (after this commit):
- [ ] Deprecate the `@babel/plugin-syntax-*` packages.
- [ ] Deprecate the `@babel/plugin-proposal-*` packages.
- [ ] Create the `@babel/plugin-transform-*` packages.