fix(es/transforms/base): Fix span hygiene of type elements (#1436)

swc_ecma_transforms_base:
 - `ts_resolver`: Fix span hygiene of type elements.
This commit is contained in:
강동윤 2021-02-28 15:55:20 +09:00 committed by GitHub
parent c047e0e54d
commit a4d408dc6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 64 additions and 42 deletions

View File

@ -2,8 +2,6 @@
Thank you for your interest in contributing to swc! Good places to start are this document, ARCHITECTURE.md, which describes the high-level structure of swc and E-easy bugs on the issue tracker.
## Code of Conduct
All contributors are expected to follow our [Code of Conduct].
@ -37,8 +35,8 @@ Please feel free to open an issue or to send a pr.
## Working on issues
If you're looking for somewhere to start, check out the [E-easy][E-Easy] and
[E-mentor][E-mentor] tags.
If you're looking for somewhere to start, check out the [E-easy][e-easy] and
[E-mentor][e-mentor] tags.
Feel free to ask for guidelines on how to tackle a problem on [gitter][] or open a
[new issue][new-issues]. This is especially important if you want to add new
@ -60,20 +58,20 @@ passes the test-suite at all times.
Your basic steps to get going:
* Fork swc and create a branch from master for the issue you are working on.
* Please adhere to the code style that you see around the location you are
working on.
* [Commit as you go][githelp].
* Include tests that cover all non-trivial code. The existing tests
in `test/` provide templates on how to test swc's behavior in a
sandbox-environment. The internal crate `testing` provides a vast amount
of helpers to minimize boilerplate. See [`testing/lib.rs`] for an
introduction to writing tests.
* Make sure `cargo test` passes.
* All code changes are expected to comply with the formatting suggested by `rustfmt`.
You can use `rustup component add --toolchain nightly rustfmt-preview` to install `rustfmt` and use
`rustfmt +nightly --unstable-features --skip-children` on the changed files to automatically format your code.
* Push your commits to GitHub and create a pull request against swc's `master` branch.
- Fork swc and create a branch from master for the issue you are working on.
- Please adhere to the code style that you see around the location you are
working on.
- [Commit as you go][githelp].
- Include tests that cover all non-trivial code. The existing tests
in `test/` provide templates on how to test swc's behavior in a
sandbox-environment. The internal crate `testing` provides a vast amount
of helpers to minimize boilerplate. See [`testing/lib.rs`] for an
introduction to writing tests.
- Make sure `cargo test` passes.
- All code changes are expected to comply with the formatting suggested by `rustfmt`.
You can use `rustup component add --toolchain nightly rustfmt-preview` to install `rustfmt` and use
`rustfmt +nightly --unstable-features --skip-children` on the changed files to automatically format your code.
- Push your commits to GitHub and create a pull request against swc's `master` branch.
## Getting your development environment set up
@ -100,7 +98,11 @@ After cloning the project there are a few steps required to get the project runn
export PATH="$PATH:$PWD/ecmascript/transforms/node_modules/.bin"
```
4. Run tests
4. Install deno, if you are going to work on the bundler.
See [official install guide of deno](https://deno.land/manual/getting_started/installation) to install it.
5. Run tests
```bash
cargo test --all --all-features
@ -145,35 +147,33 @@ updated sort][lru] is good for finding issues like this.
Contributors with sufficient permissions on the Rust-repository can help by
adding labels to triage issues:
* Yellow, **A**-prefixed labels state which **area** of the project an issue
- Yellow, **A**-prefixed labels state which **area** of the project an issue
relates to.
* Magenta, **B**-prefixed labels identify bugs which are **blockers**.
- Magenta, **B**-prefixed labels identify bugs which are **blockers**.
* Red, **C**-prefixed labels represent the **category** of an issue.
In particular, **C-feature-request** marks *proposals* for new features. If
- Red, **C**-prefixed labels represent the **category** of an issue.
In particular, **C-feature-request** marks _proposals_ for new features. If
an issue is **C-feature-request**, but is not **Feature accepted**,
then it was not thoroughly discussed, and might need some additional design
or perhaps should be implemented as an external subcommand first. Ping
@swc-projcet/swc if you want to send a PR for an such issue.
* Green, **E**-prefixed labels explain the level of **experience** or
**effort** necessary to fix the issue. [**E-mentor**][E-mentor] issues also
- Green, **E**-prefixed labels explain the level of **experience** or
**effort** necessary to fix the issue. [**E-mentor**][e-mentor] issues also
have some instructions on how to get started.
* Purple gray, **O**-prefixed labels are the **operating system** or platform
- Purple gray, **O**-prefixed labels are the **operating system** or platform
that this issue is specific to.
* Orange, **P**-prefixed labels indicate a bug's **priority**.
* Light orange, **L**-prefixed labels indicate language related to the bug.
- Orange, **P**-prefixed labels indicate a bug's **priority**.
- Light orange, **L**-prefixed labels indicate language related to the bug.
[gist]: https://gist.github.com/
[new-issues]: https://github.com/swc-project/swc/issues/new
[E-easy]: https://github.com/swc-project/swc/labels/E-easy
[E-mentor]: https://github.com/swc-project/swc/labels/E-mentor
[Code of Conduct]: https://www.rust-lang.org/conduct.html
[e-easy]: https://github.com/swc-project/swc/labels/E-easy
[e-mentor]: https://github.com/swc-project/swc/labels/E-mentor
[code of conduct]: https://www.rust-lang.org/conduct.html
[gitter]: https://gitter.im/swcproject/Lobby
[`testing/lib.rs`]: https://github.com/swc-project/swc/blob/master/testing/src/lib.rs
[irlo]: https://internals.rust-lang.org/

View File

@ -6,7 +6,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc_ecma_transforms_base"
repository = "https://github.com/swc-project/swc.git"
version = "0.6.0"
version = "0.6.1"
[dependencies]
fxhash = "0.2.1"

View File

@ -576,7 +576,9 @@ impl<'a> VisitMut for Resolver<'a> {
child.in_type = true;
n.type_params.visit_mut_with(&mut child);
n.key.visit_mut_with(&mut child);
if n.computed {
n.key.visit_mut_with(&mut child);
}
n.params.visit_mut_with(&mut child);
n.type_ann.visit_mut_with(&mut child);
}
@ -587,7 +589,9 @@ impl<'a> VisitMut for Resolver<'a> {
}
self.in_type = true;
n.key.visit_mut_with(self);
if n.computed {
n.key.visit_mut_with(self);
}
let child_mark = Mark::fresh(self.mark);
// Child folder
let mut child = Resolver::new(

View File

@ -1279,11 +1279,11 @@ const bar = {} as Foo;
",
"
interface Foo {
name: string;
name__0: string;
}
function foo() {
interface Foo__2 {
name: string;
name__0: string;
}
const foo__2 = {
} as Foo__2;
@ -1873,10 +1873,10 @@ to_ts!(
",
"
interface A<T__2> {
x: T__2;
x__0: T__2;
}
interface B {
m: string;
m__0: string;
}
var x: any;
var y = x as A<B>[];
@ -1899,10 +1899,10 @@ to_ts!(
"
module Top {
interface A__2<T__3> {
x: T__3;
x__0: T__3;
}
interface B__2 {
m: string;
m__0: string;
}
var x: any;
var y = x as A__2<B__2>[];
@ -2229,3 +2229,21 @@ to_ts!(
}
"
);
to_ts!(
tsc_conformance_types_type_aliases_type_aliases_1,
"
interface I6 { x : string }
type T6 = I6;
var x6: I6;
var x6: T6;
",
"
interface I6 {
x__0: string;
}
type T6 = I6;
var x6: I6;
var x6: T6;
"
);