Re-exporting a default export that doesn't exist with allowSyntheticDefaultExports true causes assert failures in getDefaultExportInfoWorker #29227
Labels
Bug
A bug in TypeScript
Crash
For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output
Domain: Completion Lists
The issue relates to showing completion lists in an editor
Milestone
Ever since VSCode 1.28.x started using Typescript 3.x, we've been unable to use code completion or auto imports due to the assert within "getDefaultExportInfoWorker" where it validated that the alias for a default export was set. This would cause an incomprehensible error within getCodeFixes and completionEntryDetails as reported in the comment microsoft/vscode#61660 (comment)
Errors with line numbers as reported in typescript 3.3.0-dev.20190101:
The error had been occurring for typescript 3.0.x, 3.1.x, 3.2.x, 3.3.x. Typescript 2.9.2 was not throwing the assert failures, so VSCode would function with a workspace setting of typescript 2.9.2 (though losing other functionality that depended on typescript 3.x) & code would still compile without issues in all typescript versions.
The assert and stack trace provide no details with which to identify where the problem that is causing the assert failure is coming from.
These errors then break both code-completion information (file locations, documentation, etc) and auto-imports in VSCode 1.28.x-1.30.x. Several interrelated bugs have also been causing issues for those items, resulting in the original issues being closed as fixed when some people were still having problems without being able to identify why.
After spending two days tracing through the issue:
When in ES6 mode with allowSyntheticDefaultExports, no warning/error is produced for re-exporting a default export that doesn't exist. As such, the only way the user knows that there is an error somewhere (but with no information about where) is when the typescript language server starts throwing assert failures that break VSCode's code completion & auto-import functionality.
TypeScript Version: 3.0.x, 3.1.x, 3.2.x, 3.3.0-dev.20190101
Search Terms: default export, allowSyntheticDefaultExports, alias, getDefaultExportInfoWorker, getCodeFixes, completionEntryDetails.
Code
componentA/A.tsx
componentA/index.tsx
Expected behavior:
Typescript should identify and report that the
export { default }
line incomponentA/index.tsx
is an error regardless of whetherallowSyntheticDefaultExports
is true or false.Actual behavior:
When
allowSyntheticDefaultExports
is true, no error is reported and the typescript language server instead throws assertion failures ingetDefaultExportInfoWorker
that result in breaking VSCode's code completion info and auto-import functionality.Related Issues:
microsoft/vscode#61660
#28149
#27636
#27640
The text was updated successfully, but these errors were encountered: