Skip to content

Fix crash when serializing default export in error #61582

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6127,7 +6127,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
},
isOptionalParameter,
isUndefinedIdentifierExpression(node: Identifier) {
Debug.assert(isExpressionNode(node));
Copy link
Member Author

@andrewbranch andrewbranch Apr 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The identifier being passed in was the foo of an export default foo, which is an expression, but doesn’t return true in this syntactic check because export default SomeType is also legal. I’m not sure if this assertion really needs to be here in any form. (cc @dragomirtitian)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ref #60692

return getSymbolAtLocation(node) === undefinedSymbol;
},
isEntityNameVisible(context, entityName, shouldComputeAliasToMakeVisible) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/index.ts(7,7): error TS2322: Type '{ default: { configs: { 'stage-0': PluginConfig; }; }; configs: { 'stage-0': PluginConfig; }; }' is not assignable to type 'Plugin'.
Types of property 'configs' are incompatible.
Type '{ 'stage-0': PluginConfig; }' is not assignable to type 'Record<string, { parser: string | null; }>'.
Property ''stage-0'' is incompatible with index signature.
Type 'PluginConfig' is not assignable to type '{ parser: string | null; }'.
Types of property 'parser' are incompatible.
Type 'string | null | undefined' is not assignable to type 'string | null'.
Type 'undefined' is not assignable to type 'string | null'.


==== /node_modules/eslint-plugin-import-x/package.json (0 errors) ====
{
"name": "eslint-plugin-import-x",
"version": "1.0.0",
"main": "index.cjs"
}

==== /node_modules/eslint-plugin-import-x/index.d.cts (0 errors) ====
declare const eslintPluginImportX: typeof import("./lib/index.js");
export = eslintPluginImportX;

==== /node_modules/eslint-plugin-import-x/lib/index.d.ts (0 errors) ====
interface PluginConfig {
parser?: string | null;
}
declare const configs: {
'stage-0': PluginConfig;
};
declare const _default: {
configs: {
'stage-0': PluginConfig;
};
};
export default _default;
export { configs };

==== /index.ts (1 errors) ====
import * as pluginImportX from 'eslint-plugin-import-x'

interface Plugin {
configs?: Record<string, { parser: string | null }>
}

const p: Plugin = pluginImportX;
~
!!! error TS2322: Type '{ default: { configs: { 'stage-0': PluginConfig; }; }; configs: { 'stage-0': PluginConfig; }; }' is not assignable to type 'Plugin'.
!!! error TS2322: Types of property 'configs' are incompatible.
!!! error TS2322: Type '{ 'stage-0': PluginConfig; }' is not assignable to type 'Record<string, { parser: string | null; }>'.
!!! error TS2322: Property ''stage-0'' is incompatible with index signature.
!!! error TS2322: Type 'PluginConfig' is not assignable to type '{ parser: string | null; }'.
!!! error TS2322: Types of property 'parser' are incompatible.
!!! error TS2322: Type 'string | null | undefined' is not assignable to type 'string | null'.
!!! error TS2322: Type 'undefined' is not assignable to type 'string | null'.

39 changes: 39 additions & 0 deletions tests/cases/compiler/exportAssignmentExpressionIsExpressionNode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// @strict: true
// @module: nodenext
// @noEmit: true
// @noTypesAndSymbols: true

// @Filename: /node_modules/eslint-plugin-import-x/package.json
{
"name": "eslint-plugin-import-x",
"version": "1.0.0",
"main": "index.cjs"
}

// @Filename: /node_modules/eslint-plugin-import-x/index.d.cts
declare const eslintPluginImportX: typeof import("./lib/index.js");
export = eslintPluginImportX;

// @Filename: /node_modules/eslint-plugin-import-x/lib/index.d.ts
interface PluginConfig {
parser?: string | null;
}
declare const configs: {
'stage-0': PluginConfig;
};
declare const _default: {
configs: {
'stage-0': PluginConfig;
};
};
export default _default;
export { configs };

// @Filename: /index.ts
import * as pluginImportX from 'eslint-plugin-import-x'

interface Plugin {
configs?: Record<string, { parser: string | null }>
}

const p: Plugin = pluginImportX;