Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix(39373): const {} = require import causes Debug Failure#39567

Merged
DanielRosenwasser merged 1 commit into
microsoft:mastermicrosoft/TypeScript:masterfrom
a-tarasyuk:bug/39373a-tarasyuk/TypeScript:bug/39373Copy head branch name to clipboard
Jul 17, 2020
Merged

fix(39373): const {} = require import causes Debug Failure#39567
DanielRosenwasser merged 1 commit into
microsoft:mastermicrosoft/TypeScript:masterfrom
a-tarasyuk:bug/39373a-tarasyuk/TypeScript:bug/39373Copy head branch name to clipboard

Conversation

@a-tarasyuk

@a-tarasyuk a-tarasyuk commented Jul 11, 2020

Copy link
Copy Markdown
Contributor

Fixes #39373

@a-tarasyuk a-tarasyuk force-pushed the bug/39373 branch 4 times, most recently from 0ea45f3 to 4eeb747 Compare July 12, 2020 04:00
@DanielRosenwasser

Copy link
Copy Markdown
Member

Generally we use getNameOfDeclaration or something like that to avoid duplicating the diagnostic. It'll fill it in with something like (anonymous) or (default).

@a-tarasyuk

a-tarasyuk commented Jul 14, 2020

Copy link
Copy Markdown
Contributor Author

@DanielRosenwasser Thanks for the feedback 👍. Actually, getHeritageClauseVisibilityError uses it

typeName: getNameOfDeclaration(node.parent.parent as Declaration)

and it returns undefined for the case

export default class extends Foo {}

Based on the type definition, a name can be undefined, however, that case was not handled in getHeritageClauseVisibilityError.

/** May be undefined in `export default class { ... }`. */
readonly name?: Identifier;

For that reason, TS crashes because it uses diagnostic messages with two arguments, however, receive only one.

context.addDiagnostic(createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode,
errorInfo.diagnosticMessage,
symbolAccessibilityResult.errorSymbolName,
symbolAccessibilityResult.errorModuleName));

Do you propose to replace the missed name by creating Identifier with the(anonymous) name instead of using a new diagnostic message? I think we can do it, just need to create a new Identifier and change the logic to getting text because a new Identifier will not be present in the source file.

context.addDiagnostic(createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode,
errorInfo.diagnosticMessage,
getTextOfNode(errorInfo.typeName),

@typescript-bot typescript-bot added the For Milestone Bug PRs that fix a bug with a specific milestone label Jul 16, 2020
@DanielRosenwasser

Copy link
Copy Markdown
Member

Actually I think it's fine, especially since functions have the same diagnostic.

@DanielRosenwasser DanielRosenwasser merged commit 4e24b1b into microsoft:master Jul 17, 2020
@DanielRosenwasser

Copy link
Copy Markdown
Member

I actually realized that the test might need to be changed to use at least one .js file because of #39617...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Milestone Bug PRs that fix a bug with a specific milestone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

const {} = require import causes Debug Failure

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.