Duplicating lines of code
See original GitHub issueI am testing out ts-migrate-full on a large project that uses an older version of react. ts-migrate (maybe the explicit-any plugin??) doesn’t seem to be properly replacing code in some plain .js
files, as you can see in the code snippet below.
Before
var window = {
onResetData: function() {
this.clearNextPush = function() {
this.resetHistoryResumeData();
this.setState({ history: [] });
pubSub.trigger(events.window.CLEAR_HISTORY);
};
},
// more code here
}
After
var window = {
onResetData: function() {
(this as any).clearNextPush = function () {
this.resetHistoryResumeData();
this.setState({ history: [] });
pubSub.trigger(events.window.CLEAR_HISTORY);
};
(this as any).setState({ history: [] });
pubSub.trigger(events.window.CLEAR_HISTORY);
};
},
// more code here
}
Expected
var window = {
onResetData: function() {
(this as any).clearNextPush = function () {
this.resetHistoryResumeData();
(this as any).setState({ history: [] });
pubSub.trigger(events.window.CLEAR_HISTORY);
};
},
// more code here
}
I am seeing ~1000 errors from tsc but its really just ~200 instances this thought the code base. Manually fixing these bugs isn’t that bad, when compared to all the other work ts-migrate did for me.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Duplicate line in Visual Studio Code - Stack Overflow
The duplicate can be achieved by CTRL + C and CTRL + V with ...
Read more >Duplicate line or selection - ReSharper - JetBrains
Press Ctrl+D or choose ReSharper | Edit | Duplicate Text from the main menu . Alternatively, you can press Ctrl+Shift+A , start typing...
Read more >Duplicate code - Wikipedia
In computer programming, duplicate code is a sequence of source code that occurs more than once, either within a program or across different...
Read more >Duplicate Code - Refactoring.Guru
Duplication usually occurs when multiple programmers are working on different parts of the same program at the same time. Since they're working on...
Read more >How to create a duplicate line in VSCode? - W3schools.io
How to create a duplicate line in VSCode? · Windows: Shift + Alt+ Down key and Shift + Alt+ Up key · Linux:...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@shawngustaw sorry for the delay, done
@doncollins Sadly its not simple as just adding
Block
to the ancestor node check. While it fixes the duplication in the example above, it also adds an extra trailing\n
character and causes other tests to fail.