forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 3
Fix JSX comment duplication in preserve mode #13
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
Draft
Copilot
wants to merge
8
commits into
main
Choose a base branch
from
copilot/fix-11-2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fbaed54
Initial plan
Copilot f4f38c0
Initial investigation of JSX comment duplication issue
Copilot 2aa5757
Fix attempt for JSX comment duplication - not working yet
Copilot 804dddc
Fix JSX comment duplication issue
Copilot 68b4475
Final cleanup and lint fixes for JSX comment duplication fix
Copilot 0cb049f
Fix JSX comment duplication by excluding JSX text ranges from comment…
Copilot 381423f
Add question about JSX comment handling to documentation
Copilot 93c7172
Improve JSX comment duplication fix - use targeted node traversal ins…
Copilot 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
Questions I have that I think the developers of this project can help me with: | ||
* How does control flow analysis represent a circular graph? I checked the documentation server for "cfa" and "control flow" | ||
* How do I tell if a symbol is in the global scope? I checked the documentation server for topics referencing "symbol" and "global" | ||
* What is an `EscapedName`, exactly? | ||
Questions I have that I think the developers of this project can help me with: | ||
* How does control flow analysis represent a circular graph? I checked the documentation server for "cfa" and "control flow" | ||
* How do I tell if a symbol is in the global scope? I checked the documentation server for topics referencing "symbol" and "global" | ||
* What is an `EscapedName`, exactly? | ||
* How does TypeScript distinguish between comments inside JSX text vs regular TypeScript comments? I searched for "JSX text comments emitter forEachTrailingCommentRange JSX text ranges" - The issue was that comment iteration doesn't understand JSX context and treats JSX text content as regular comments. |
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
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,9 @@ | ||
//// [tests/cases/compiler/jsxCommentDuplication.tsx] //// | ||
|
||
//// [jsxCommentDuplication.tsx] | ||
function App() {} | ||
const jsx = <App>/* no */{/* 1 */ 123 /* 2 */}/* no */</App>; | ||
|
||
//// [jsxCommentDuplication.jsx] | ||
function App() { } | ||
var jsx = <App>/* no */{/* 1 */123 /* 2 */}/* no */</App>; |
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,11 @@ | ||
//// [tests/cases/compiler/jsxCommentDuplication.tsx] //// | ||
|
||
=== jsxCommentDuplication.tsx === | ||
function App() {} | ||
>App : Symbol(App, Decl(jsxCommentDuplication.tsx, 0, 0)) | ||
|
||
const jsx = <App>/* no */{/* 1 */ 123 /* 2 */}/* no */</App>; | ||
>jsx : Symbol(jsx, Decl(jsxCommentDuplication.tsx, 1, 5)) | ||
>App : Symbol(App, Decl(jsxCommentDuplication.tsx, 0, 0)) | ||
>App : Symbol(App, Decl(jsxCommentDuplication.tsx, 0, 0)) | ||
|
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,17 @@ | ||
//// [tests/cases/compiler/jsxCommentDuplication.tsx] //// | ||
|
||
=== jsxCommentDuplication.tsx === | ||
function App() {} | ||
>App : () => void | ||
> : ^^^^^^^^^^ | ||
|
||
const jsx = <App>/* no */{/* 1 */ 123 /* 2 */}/* no */</App>; | ||
>jsx : error | ||
><App>/* no */{/* 1 */ 123 /* 2 */}/* no */</App> : error | ||
>App : () => void | ||
> : ^^^^^^^^^^ | ||
>123 : 123 | ||
> : ^^^ | ||
>App : () => void | ||
> : ^^^^^^^^^^ | ||
|
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,9 @@ | ||
//// [tests/cases/compiler/jsxCommentDuplicationDebug.tsx] //// | ||
|
||
//// [jsxCommentDuplicationDebug.tsx] | ||
function App() {} | ||
const jsx = <App>/* before */{/* 1 */ 123 /* 2 */}/* after */</App>; | ||
|
||
//// [jsxCommentDuplicationDebug.jsx] | ||
function App() { } | ||
var jsx = <App>/* before */{123}/* after */</App>; |
11 changes: 11 additions & 0 deletions
11
tests/baselines/reference/jsxCommentDuplicationDebug.symbols
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,11 @@ | ||
//// [tests/cases/compiler/jsxCommentDuplicationDebug.tsx] //// | ||
|
||
=== jsxCommentDuplicationDebug.tsx === | ||
function App() {} | ||
>App : Symbol(App, Decl(jsxCommentDuplicationDebug.tsx, 0, 0)) | ||
|
||
const jsx = <App>/* before */{/* 1 */ 123 /* 2 */}/* after */</App>; | ||
>jsx : Symbol(jsx, Decl(jsxCommentDuplicationDebug.tsx, 1, 5)) | ||
>App : Symbol(App, Decl(jsxCommentDuplicationDebug.tsx, 0, 0)) | ||
>App : Symbol(App, Decl(jsxCommentDuplicationDebug.tsx, 0, 0)) | ||
|
17 changes: 17 additions & 0 deletions
17
tests/baselines/reference/jsxCommentDuplicationDebug.types
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,17 @@ | ||
//// [tests/cases/compiler/jsxCommentDuplicationDebug.tsx] //// | ||
|
||
=== jsxCommentDuplicationDebug.tsx === | ||
function App() {} | ||
>App : () => void | ||
> : ^^^^^^^^^^ | ||
|
||
const jsx = <App>/* before */{/* 1 */ 123 /* 2 */}/* after */</App>; | ||
>jsx : error | ||
><App>/* before */{/* 1 */ 123 /* 2 */}/* after */</App> : error | ||
>App : () => void | ||
> : ^^^^^^^^^^ | ||
>123 : 123 | ||
> : ^^^ | ||
>App : () => void | ||
> : ^^^^^^^^^^ | ||
|
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
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,3 @@ | ||
// @jsx: preserve | ||
function App() {} | ||
const jsx = <App>/* no */{/* 1 */ 123 /* 2 */}/* no */</App>; |
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.