Using the TypeScript compiler to fix erroneous Node.js snippets
Brittany Reid, Christoph Treude, Markus Wagner

TL;DR
This paper introduces Node Code Correction (NCC), an automated approach leveraging the TypeScript compiler to detect and fix errors in Node.js code snippets, significantly improving code reuse efficiency.
Contribution
The paper presents NCC, a novel method that uses TypeScript's error detection and codefixes to automatically correct errors in Node.js snippets, outperforming existing linters.
Findings
NCC detects more error types than linters.
73.7% of NPM snippets contain errors.
NCC reduces errors in snippets from 73.7% to 25.1%.
Abstract
Most online code snippets do not run. This means that developers looking to reuse code from online sources must manually find and fix errors. We present an approach for automatically evaluating and correcting errors in Node.js code snippets: Node Code Correction (NCC). NCC leverages the ability of the TypeScript compiler to generate errors and inform code corrections through the combination of TypeScript's built-in codefixes, our own targeted fixes, and deletion of erroneous lines. Compared to existing approaches using linters, our findings suggest that NCC is capable of detecting a larger number of errors per snippet and more error types, and it is more efficient at fixing snippets. We find that 73.7% of the code snippets in NPM documentation have errors; with the use of NCC's corrections, this number was reduced to 25.1%. Our evaluation confirms that the use of the TypeScript compiler…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsSoftware Engineering Research · Scientific Computing and Data Management · Software System Performance and Reliability
