Repository navigation
fix(ts-optimizer): respect bindings that shadow destructured props #9133
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,5 @@ | ||
| --- | ||
| '@qwik.dev/core': patch | ||
| --- | ||
|
|
||
| fix: the TypeScript optimizer no longer mistakes a local for a prop or import of the same name | ||
This file contains hidden or 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
103 changes: 103 additions & 0 deletions
103
...ges/optimizer/core/src/snapshots/qwik_core__test__captured_props_shadowed_in_segment.snap
This file contains hidden or 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,103 @@ | ||
| --- | ||
| source: packages/optimizer/core/src/test.rs | ||
| expression: output | ||
| --- | ||
| ==INPUT== | ||
|
|
||
|
|
||
| import { component$ } from '@qwik.dev/core'; | ||
| import { Fallback, render } from './x'; | ||
|
|
||
| export const Cmp = component$(({ Model = Fallback }: { Model?: any }) => { | ||
| return <button onClick$={() => render(Model, [1].map((Model) => Model))} />; | ||
| }); | ||
|
|
||
| ============================= test.js == | ||
|
|
||
| import { componentQrl } from "@qwik.dev/core"; | ||
| import { qrl } from "@qwik.dev/core"; | ||
| // | ||
| const q_Cmp_component_4ryKJTOKjWE = /*#__PURE__*/ qrl(()=>import("./test.tsx_Cmp_component_4ryKJTOKjWE"), "Cmp_component_4ryKJTOKjWE"); | ||
| // | ||
| export const Cmp = /*#__PURE__*/ componentQrl(q_Cmp_component_4ryKJTOKjWE); | ||
|
|
||
|
|
||
| Some("{\"version\":3,\"sources\":[\"/user/qwik/src/test.tsx\"],\"names\":[],\"mappings\":\";;;;;AAIA,OAAO,MAAM,oBAAM,0CAEhB\"}") | ||
| ============================= test.tsx_Cmp_component_button_q_e_click_0O0tA6ahzDQ.js (ENTRY POINT)== | ||
|
|
||
| import { Fallback } from "./x"; | ||
| import { render } from "./x"; | ||
| // | ||
| export const Cmp_component_button_q_e_click_0O0tA6ahzDQ = (_, _1, _rawProps)=>render(_rawProps.Model ?? Fallback, [ | ||
| 1 | ||
| ].map((Model)=>Model)); | ||
|
|
||
|
|
||
| Some("{\"version\":3,\"sources\":[\"/user/qwik/src/test.tsx\"],\"names\":[],\"mappings\":\";;;0DAK0B,oBAAM,iBADC,SAAQ,UACK;QAAC;KAAE,CAAC,GAAG,CAAC,CAAC,QAAU\"}") | ||
| /* | ||
| { | ||
| "origin": "test.tsx", | ||
| "name": "Cmp_component_button_q_e_click_0O0tA6ahzDQ", | ||
| "entry": null, | ||
| "displayName": "test.tsx_Cmp_component_button_q_e_click", | ||
| "hash": "0O0tA6ahzDQ", | ||
| "canonicalFilename": "test.tsx_Cmp_component_button_q_e_click_0O0tA6ahzDQ", | ||
| "path": "", | ||
| "extension": "js", | ||
| "parent": "Cmp_component_4ryKJTOKjWE", | ||
| "ctxKind": "eventHandler", | ||
| "ctxName": "onClick$", | ||
| "captures": false, | ||
| "loc": [ | ||
| 189, | ||
| 235 | ||
| ], | ||
| "paramNames": [ | ||
| "_", | ||
| "_1", | ||
| "_rawProps" | ||
| ] | ||
| } | ||
| */ | ||
| ============================= test.tsx_Cmp_component_4ryKJTOKjWE.js (ENTRY POINT)== | ||
|
|
||
| import { _jsxSorted } from "@qwik.dev/core"; | ||
| import { qrl } from "@qwik.dev/core"; | ||
| // | ||
| const q_Cmp_component_button_q_e_click_0O0tA6ahzDQ = /*#__PURE__*/ qrl(()=>import("./test.tsx_Cmp_component_button_q_e_click_0O0tA6ahzDQ"), "Cmp_component_button_q_e_click_0O0tA6ahzDQ").m(); | ||
| // | ||
| export const Cmp_component_4ryKJTOKjWE = (_rawProps)=>{ | ||
| return /*#__PURE__*/ _jsxSorted("button", { | ||
| "q-e:click": q_Cmp_component_button_q_e_click_0O0tA6ahzDQ, | ||
| "q:p": _rawProps | ||
| }, null, null, 6, "u6_0"); | ||
| }; | ||
|
|
||
|
|
||
| Some("{\"version\":3,\"sources\":[\"/user/qwik/src/test.tsx\"],\"names\":[],\"mappings\":\";;;;;yCAI8B;IAC7B,qBAAO,WAAC;QAAO,WAAQ;;;AACxB\"}") | ||
| /* | ||
| { | ||
| "origin": "test.tsx", | ||
| "name": "Cmp_component_4ryKJTOKjWE", | ||
| "entry": null, | ||
| "displayName": "test.tsx_Cmp_component", | ||
| "hash": "4ryKJTOKjWE", | ||
| "canonicalFilename": "test.tsx_Cmp_component_4ryKJTOKjWE", | ||
| "path": "", | ||
| "extension": "js", | ||
| "parent": null, | ||
| "ctxKind": "function", | ||
| "ctxName": "component$", | ||
| "captures": false, | ||
| "loc": [ | ||
| 118, | ||
| 242 | ||
| ], | ||
| "paramNames": [ | ||
| "_rawProps" | ||
| ] | ||
| } | ||
| */ | ||
| == DIAGNOSTICS == | ||
|
|
||
| [] |
47 changes: 47 additions & 0 deletions
47
...imizer/core/src/snapshots/qwik_core__test__captured_props_shadowed_in_segment_inline.snap
This file contains hidden or 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,47 @@ | ||
| --- | ||
| source: packages/optimizer/core/src/test.rs | ||
| expression: output | ||
| --- | ||
| ==INPUT== | ||
|
|
||
|
|
||
| import { $, component$ } from '@qwik.dev/core'; | ||
| import { Fallback, render } from './x'; | ||
|
|
||
| export const Cmp = component$(({ Model = Fallback }: { Model?: any }) => { | ||
| const read = $(() => render(Model, [1].map((Model) => Model))); | ||
| return <button onClick$={read} />; | ||
| }); | ||
|
|
||
| ============================= test.js == | ||
|
|
||
| import { componentQrl } from "@qwik.dev/core"; | ||
| import { _capturesObj } from "@qwik.dev/core"; | ||
| import { _noopQrl } from "@qwik.dev/core"; | ||
| import { _jsxSorted } from "@qwik.dev/core"; | ||
| import { Fallback, render } from './x'; | ||
| // | ||
| const q_Cmp_component_4ryKJTOKjWE = /*#__PURE__*/ _noopQrl("Cmp_component_4ryKJTOKjWE"); | ||
| const q_Cmp_component_read_hAtqXQFCN20 = /*#__PURE__*/ _noopQrl("Cmp_component_read_hAtqXQFCN20"); | ||
| // | ||
| q_Cmp_component_read_hAtqXQFCN20.s(()=>{ | ||
| let _rawProps = _capturesObj._[0]; | ||
| return render(_rawProps.Model ?? Fallback, [ | ||
| 1 | ||
| ].map((Model)=>Model)); | ||
| }); | ||
| q_Cmp_component_4ryKJTOKjWE.s((_rawProps)=>{ | ||
| const read = q_Cmp_component_read_hAtqXQFCN20.w([ | ||
| _rawProps | ||
| ]); | ||
| return /*#__PURE__*/ _jsxSorted("button", null, { | ||
| "q-e:click": read | ||
| }, null, 3, "u6_0"); | ||
| }); | ||
| export const Cmp = /*#__PURE__*/ componentQrl(q_Cmp_component_4ryKJTOKjWE); | ||
|
|
||
|
|
||
| Some("{\"version\":3,\"sources\":[\"/user/qwik/src/test.tsx\"],\"names\":[],\"mappings\":\";;;;AAEA,SAAS,QAAQ,EAAE,MAAM,QAAQ,MAAM;;;;;mCAGvB;;WAAM,iBADW,SAAQ,UACL;QAAC;KAAE,CAAC,GAAG,CAAC,CAAC,QAAU;;8BADzB;IAC7B,MAAM;;;IACN,qBAAO,WAAC;QAAO,aAAU;;AAC1B;AAHA,OAAO,MAAM,oBAAM,0CAGhB\"}") | ||
| == DIAGNOSTICS == | ||
|
|
||
| [] |
101 changes: 101 additions & 0 deletions
101
...mizer/core/src/snapshots/qwik_core__test__should_keep_loop_params_named_like_imports.snap
This file contains hidden or 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,101 @@ | ||
| --- | ||
| source: packages/optimizer/core/src/test.rs | ||
| expression: output | ||
| --- | ||
| ==INPUT== | ||
|
|
||
|
|
||
| import { component$ } from '@qwik.dev/core'; | ||
| import { item } from './x'; | ||
|
|
||
| export const List = component$(({ items }: { items: string[] }) => { | ||
| console.log(item); | ||
| return <ul>{items.map((item) => <li onClick$={() => console.log(item)} />)}</ul>; | ||
| }); | ||
|
|
||
| ============================= test.js == | ||
|
|
||
| import { componentQrl } from "@qwik.dev/core"; | ||
| import { qrl } from "@qwik.dev/core"; | ||
| // | ||
| const q_List_component_HpIwcodkEXk = /*#__PURE__*/ qrl(()=>import("./test.tsx_List_component_HpIwcodkEXk"), "List_component_HpIwcodkEXk"); | ||
| // | ||
| export const List = /*#__PURE__*/ componentQrl(q_List_component_HpIwcodkEXk); | ||
|
|
||
|
|
||
| Some("{\"version\":3,\"sources\":[\"/user/qwik/src/test.tsx\"],\"names\":[],\"mappings\":\";;;;;AAIA,OAAO,MAAM,qBAAO,2CAGjB\"}") | ||
| ============================= test.tsx_List_component_HpIwcodkEXk.js (ENTRY POINT)== | ||
|
|
||
| import { _jsxSorted } from "@qwik.dev/core"; | ||
| import { item } from "./x"; | ||
| import { qrl } from "@qwik.dev/core"; | ||
| // | ||
| const q_List_component_ul_li_q_e_click_7DhcqJDaP4Q = /*#__PURE__*/ qrl(()=>import("./test.tsx_List_component_ul_li_q_e_click_7DhcqJDaP4Q"), "List_component_ul_li_q_e_click_7DhcqJDaP4Q").m(); | ||
| // | ||
| export const List_component_HpIwcodkEXk = (_rawProps)=>{ | ||
| console.log(item); | ||
| return /*#__PURE__*/ _jsxSorted("ul", null, null, _rawProps.items.map((item)=>/*#__PURE__*/ _jsxSorted("li", { | ||
| "q-e:click": q_List_component_ul_li_q_e_click_7DhcqJDaP4Q, | ||
| "q:p": item | ||
| }, null, null, 6, "u6_0")), 1, "u6_1"); | ||
| }; | ||
|
|
||
|
|
||
| Some("{\"version\":3,\"sources\":[\"/user/qwik/src/test.tsx\"],\"names\":[],\"mappings\":\";;;;;;0CAI+B;IAC9B,QAAQ,GAAG,CAAC;IACZ,qBAAO,WAAC,kBAAI,UAFqB,MAEf,GAAG,CAAC,CAAC,qBAAS,WAAC;YAAG,WAAQ;mBAArB;;AACxB\"}") | ||
| /* | ||
| { | ||
| "origin": "test.tsx", | ||
| "name": "List_component_HpIwcodkEXk", | ||
| "entry": null, | ||
| "displayName": "test.tsx_List_component", | ||
| "hash": "HpIwcodkEXk", | ||
| "canonicalFilename": "test.tsx_List_component_HpIwcodkEXk", | ||
| "path": "", | ||
| "extension": "js", | ||
| "parent": null, | ||
| "ctxKind": "function", | ||
| "ctxName": "component$", | ||
| "captures": false, | ||
| "loc": [ | ||
| 107, | ||
| 249 | ||
| ], | ||
| "paramNames": [ | ||
| "_rawProps" | ||
| ] | ||
| } | ||
| */ | ||
| ============================= test.tsx_List_component_ul_li_q_e_click_7DhcqJDaP4Q.js (ENTRY POINT)== | ||
|
|
||
| export const List_component_ul_li_q_e_click_7DhcqJDaP4Q = (_, _1, item)=>console.log(item); | ||
|
|
||
|
|
||
| Some("{\"version\":3,\"sources\":[\"/user/qwik/src/test.tsx\"],\"names\":[],\"mappings\":\"0DAM+C,QAAvB,OAA6B,QAAQ,GAAG,CAAC\"}") | ||
| /* | ||
| { | ||
| "origin": "test.tsx", | ||
| "name": "List_component_ul_li_q_e_click_7DhcqJDaP4Q", | ||
| "entry": null, | ||
| "displayName": "test.tsx_List_component_ul_li_q_e_click", | ||
| "hash": "7DhcqJDaP4Q", | ||
| "canonicalFilename": "test.tsx_List_component_ul_li_q_e_click_7DhcqJDaP4Q", | ||
| "path": "", | ||
| "extension": "js", | ||
| "parent": "List_component_HpIwcodkEXk", | ||
| "ctxKind": "eventHandler", | ||
| "ctxName": "onClick$", | ||
| "captures": false, | ||
| "loc": [ | ||
| 212, | ||
| 235 | ||
| ], | ||
| "paramNames": [ | ||
| "_", | ||
| "_1", | ||
| "item" | ||
| ] | ||
| } | ||
| */ | ||
| == DIAGNOSTICS == | ||
|
|
||
| [] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Shorten the changeset summary and write it in lowercase.
The summary has about 17 words and contains the capitalized term
TypeScript. The repository rules require a lowercase summary of about 10 words, with no implementation details.📝 Proposed fix
As per coding guidelines,
.changeset/**: "Write the changeset summary in lowercase (e.g.fix:)" and "1 short sentence (10-ish words) focused on the bug fix or feature."📝 Committable suggestion
🤖 Prompt for AI Agents
Source: Coding guidelines