-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Avoid crash for import code fixes with dotted require #47433
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
Changes from 4 commits
fce282b
ea2c290
d954948
f476e84
9f0810c
bf708bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4668,6 +4668,11 @@ namespace ts { | |
readonly initializer: RequireOrImportCall; | ||
} | ||
|
||
/* @internal */ | ||
export interface AccessedOrBareRequireVariableDeclaration extends VariableDeclaration { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I prefer RequireVariableDeclarationOrExpression There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd agree (less easy to miss if you're doing completion and were about to use the old one, too). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It’s not a “declaration or expression” though—it’s always a variable declaration, and the initializer of that variable declaration is always an expression. The thing that changes is whether that expression is a special call expression or a property access expression off that special call expression. I don’t like either of these names and don’t have a better suggestion ready, but I don’t understand what There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I'm going to go with |
||
readonly initializer: RequireOrImportCall | AccessExpression; | ||
} | ||
|
||
/* @internal */ | ||
export interface RequireVariableStatement extends VariableStatement { | ||
readonly declarationList: RequireVariableDeclarationList; | ||
|
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" }, | ||
]); |
Uh oh!
There was an error while loading. Please reload this page.