-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert destruction #39832
Convert destruction #39832
Conversation
@typescript-bot pack this. |
Hey @Kingwl, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build. |
@typescript-bot pack this. |
Hey @Kingwl, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build. |
Emmmmmmmm... Up |
The TypeScript team hasn't accepted the linked issue #29917. If you can get it accepted, this PR will have a better chance of being reviewed. |
Bad news.. interface I { a: string, b: number }
function foo (item: I) {
call(item./*a*/a/*b*/, item.b)
} I'm stuck on common parent node lookup....... Seems it's very expansive if we lookup on every references. |
@Kingwl is there some way we can help on this? Maybe if we had somebody look at the PR and try to think of a fast way to find common parents? (or a way to avoid needing to find them) |
I guess we can simplify the code by anders's control flow changes. |
I will pick this up soon. |
@Kingwl do you still have time to work on this? Otherwise let's close it. |
Emmmmm. I guess we can ignore about the type narrow related logic now. So It's might be more simple |
Without narrowing, it's nearly done, right? |
In my memory, yes. I'll try to pick this up today or tomorrow(UTC+8)😜 |
Shit. I guess I cannot pick this up... |
Hey @sandersn ! Would you mind give some suggestions about this? The blocker is I have no idea to find a position to insert the destruction declaration. |
You'll have to remind me: how does the current code fail to find the right position? Is it that find-all-refs for Maybe if you find-all-refs on |
@sandersn Well, It's not a good case. Below is a better one: interface I { a: string, b: number }
interface II { i: I }
function foo (item: II) {
call(item.i./*a*/a/*b*/, item.i.b)
} It's suppose to be convert as: interface I { a: string, b: number }
interface II { i: I }
function foo (item: II) {
const { a, b } = item.i
call(a, b)
} But how could I find the position to insert the destruction? |
Well, it's a good start anyway. That's the symbol that's actually in scope at the point where the refactoring is invoked. |
Fixes #29917
Fixes #25946
Fixes #30996
Well, the PR comes after 1 year.
This PR add a refactor that allow us convert between access expression and destruction.
The behavior follow below rules:
[|a|].b // apply at a
,[|a.b|].c // apply at a.b
a["xxx"] // ok
,a[foo] // not work
this
)[|a|].b()
a["w-t-f"]
Dense
index_i
as array destruction binding for Dense array destructioni: index_i
as object destruction binding for array destructionTodo:
Convert back into property accessKnown Issues