Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid crash for import code fixes with dotted require (#47433)
* Add failing test. * Update failing test. * Finalized failing test case. * Separate our usages of utilities that expect variables initialized to require(...) and require(...).foo. * Renamed types and utilities, removed accidental indentation. * Renamed both utilitiy functions uniformly.
- Loading branch information
1 parent
049d4e0
commit ad5ca67
Showing
9 changed files
with
49 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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
21 changes: 21 additions & 0 deletions
21
tests/cases/fourslash/importFixesWithExistingDottedRequire.ts
This file contains 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,21 @@ | ||
/// <reference path="./fourslash.ts" /> | ||
|
||
// @module: commonjs | ||
// @checkJs: true | ||
|
||
// @Filename: ./library.js | ||
//// module.exports.aaa = function() {} | ||
//// module.exports.bbb = function() {} | ||
|
||
// @Filename: ./foo.js | ||
//// var aaa = require("./library.js").aaa; | ||
//// aaa(); | ||
//// /*$*/bbb | ||
|
||
goTo.marker("$") | ||
verify.codeFixAvailable([ | ||
{ description: "Import 'bbb' from module \"./library.js\"" }, | ||
{ description: "Ignore this error message" }, | ||
{ description: "Disable checking for this file" }, | ||
{ description: "Convert to ES module" }, | ||
]); |