-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(50654): "Move to a new file" breaks the declaration of referenced…
… variable (#50681) * fix(50654): remove entire import require call instead of the name * handle require imports in ts files
- Loading branch information
1 parent
170a17f
commit 8b1ecdb
Showing
4 changed files
with
109 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @allowJs: true | ||
|
||
// @filename: /a.js | ||
////module.exports = 1; | ||
|
||
// @filename: /b.js | ||
////var a = require("./a"); | ||
////[|function f() { | ||
//// a; | ||
////}|] | ||
|
||
verify.noErrors(); | ||
|
||
verify.moveToNewFile({ | ||
newFileContents: { | ||
"/b.js": "", | ||
|
||
"/f.js": | ||
`var a = require("./a"); | ||
function f() { | ||
a; | ||
} | ||
`, | ||
}, | ||
}); |
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,33 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @allowJs: true | ||
|
||
// @filename: /a.js | ||
////module.exports = 1; | ||
|
||
// @filename: /b.js | ||
////var a = require("./a"), | ||
//// b = require("./a"), | ||
//// c = require("./a"); | ||
////[|function f() { | ||
//// b; | ||
////}|] | ||
|
||
verify.noErrors(); | ||
|
||
verify.moveToNewFile({ | ||
newFileContents: { | ||
"/b.js": | ||
`var a = require("./a"), | ||
c = require("./a"); | ||
`, | ||
|
||
"/f.js": | ||
`var b = require("./a"); | ||
function f() { | ||
b; | ||
} | ||
`, | ||
}, | ||
}); |
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,33 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @module: commonjs | ||
// @moduleResolution: node | ||
|
||
// @filename: /node.d.ts | ||
////declare var module: any; | ||
////declare var require: any; | ||
|
||
// @filename: /a.ts | ||
////module.exports = 1; | ||
|
||
// @filename: /b.ts | ||
////var a = require("./a"); | ||
////[|function f() { | ||
//// a; | ||
////}|] | ||
|
||
verify.noErrors(); | ||
|
||
verify.moveToNewFile({ | ||
newFileContents: { | ||
"/b.ts": "", | ||
|
||
"/f.ts": | ||
`var a = require("./a"); | ||
function f() { | ||
a; | ||
} | ||
`, | ||
}, | ||
}); |