Skip to content

Commit 8fb9251

Browse files
committed
Fix crash when serializing default export in error
1 parent eef7c14 commit 8fb9251

3 files changed

Lines changed: 94 additions & 0 deletions

File tree

src/compiler/utilities.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3647,6 +3647,7 @@ export function isInExpressionContext(node: Node): boolean {
36473647
case SyntaxKind.SwitchStatement:
36483648
case SyntaxKind.CaseClause:
36493649
case SyntaxKind.ThrowStatement:
3650+
case SyntaxKind.ExportAssignment:
36503651
return (parent as ExpressionStatement).expression === node;
36513652
case SyntaxKind.ForStatement:
36523653
const forStatement = parent as ForStatement;
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/index.ts(7,7): error TS2322: Type '{ default: { configs: { 'stage-0': PluginConfig; }; }; configs: { 'stage-0': PluginConfig; }; }' is not assignable to type 'Plugin'.
2+
Types of property 'configs' are incompatible.
3+
Type '{ 'stage-0': PluginConfig; }' is not assignable to type 'Record<string, { parser: string | null; }>'.
4+
Property ''stage-0'' is incompatible with index signature.
5+
Type 'PluginConfig' is not assignable to type '{ parser: string | null; }'.
6+
Types of property 'parser' are incompatible.
7+
Type 'string | null | undefined' is not assignable to type 'string | null'.
8+
Type 'undefined' is not assignable to type 'string | null'.
9+
10+
11+
==== /node_modules/eslint-plugin-import-x/package.json (0 errors) ====
12+
{
13+
"name": "eslint-plugin-import-x",
14+
"version": "1.0.0",
15+
"main": "index.cjs"
16+
}
17+
18+
==== /node_modules/eslint-plugin-import-x/index.d.cts (0 errors) ====
19+
declare const eslintPluginImportX: typeof import("./lib/index.js");
20+
export = eslintPluginImportX;
21+
22+
==== /node_modules/eslint-plugin-import-x/lib/index.d.ts (0 errors) ====
23+
interface PluginConfig {
24+
parser?: string | null;
25+
}
26+
declare const configs: {
27+
'stage-0': PluginConfig;
28+
};
29+
declare const _default: {
30+
configs: {
31+
'stage-0': PluginConfig;
32+
};
33+
};
34+
export default _default;
35+
export { configs };
36+
37+
==== /index.ts (1 errors) ====
38+
import * as pluginImportX from 'eslint-plugin-import-x'
39+
40+
interface Plugin {
41+
configs?: Record<string, { parser: string | null }>
42+
}
43+
44+
const p: Plugin = pluginImportX;
45+
~
46+
!!! error TS2322: Type '{ default: { configs: { 'stage-0': PluginConfig; }; }; configs: { 'stage-0': PluginConfig; }; }' is not assignable to type 'Plugin'.
47+
!!! error TS2322: Types of property 'configs' are incompatible.
48+
!!! error TS2322: Type '{ 'stage-0': PluginConfig; }' is not assignable to type 'Record<string, { parser: string | null; }>'.
49+
!!! error TS2322: Property ''stage-0'' is incompatible with index signature.
50+
!!! error TS2322: Type 'PluginConfig' is not assignable to type '{ parser: string | null; }'.
51+
!!! error TS2322: Types of property 'parser' are incompatible.
52+
!!! error TS2322: Type 'string | null | undefined' is not assignable to type 'string | null'.
53+
!!! error TS2322: Type 'undefined' is not assignable to type 'string | null'.
54+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// @strict: true
2+
// @module: nodenext
3+
// @noEmit: true
4+
// @noTypesAndSymbols: true
5+
6+
// @Filename: /node_modules/eslint-plugin-import-x/package.json
7+
{
8+
"name": "eslint-plugin-import-x",
9+
"version": "1.0.0",
10+
"main": "index.cjs"
11+
}
12+
13+
// @Filename: /node_modules/eslint-plugin-import-x/index.d.cts
14+
declare const eslintPluginImportX: typeof import("./lib/index.js");
15+
export = eslintPluginImportX;
16+
17+
// @Filename: /node_modules/eslint-plugin-import-x/lib/index.d.ts
18+
interface PluginConfig {
19+
parser?: string | null;
20+
}
21+
declare const configs: {
22+
'stage-0': PluginConfig;
23+
};
24+
declare const _default: {
25+
configs: {
26+
'stage-0': PluginConfig;
27+
};
28+
};
29+
export default _default;
30+
export { configs };
31+
32+
// @Filename: /index.ts
33+
import * as pluginImportX from 'eslint-plugin-import-x'
34+
35+
interface Plugin {
36+
configs?: Record<string, { parser: string | null }>
37+
}
38+
39+
const p: Plugin = pluginImportX;

0 commit comments

Comments
 (0)