Skip to content

Commit 738b45e

Browse files
authored
Fixed crash in checkExportsOnMergedDeclarationsWorker (#52740)
1 parent 098e18e commit 738b45e

11 files changed

+457
-0
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38808,6 +38808,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3880838808
// all of which are pretty much always values, or at least imply a value meaning.
3880938809
// It may be apprpriate to treat these as aliases in the future.
3881038810
return DeclarationSpaces.ExportValue;
38811+
case SyntaxKind.MethodSignature:
38812+
case SyntaxKind.PropertySignature:
38813+
return DeclarationSpaces.ExportType;
3881138814
default:
3881238815
return Debug.failBadSyntaxKind(d);
3881338816
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
tests/cases/compiler/index.ts(1,13): error TS2440: Import declaration conflicts with local declaration of 'pick'.
2+
tests/cases/compiler/index.ts(1,23): error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.
3+
tests/cases/compiler/index.ts(2,14): error TS7023: 'pick' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
4+
5+
6+
==== tests/cases/compiler/node_modules/@types/lodash/object.d.ts (0 errors) ====
7+
import _ = require("./index");
8+
declare module "./index" {
9+
interface LoDashStatic {
10+
pick<T extends object, U extends keyof T>(
11+
object: T,
12+
...props: Array<U>
13+
): Pick<T, U>;
14+
}
15+
}
16+
17+
==== tests/cases/compiler/node_modules/@types/lodash/pick.d.ts (0 errors) ====
18+
import { pick } from "./index";
19+
export = pick;
20+
21+
==== tests/cases/compiler/node_modules/@types/lodash/index.d.ts (0 errors) ====
22+
/// <reference path="./object.d.ts" />
23+
export = _;
24+
export as namespace _;
25+
declare const _: _.LoDashStatic;
26+
declare namespace _ {
27+
interface LoDashStatic {}
28+
}
29+
30+
==== tests/cases/compiler/index.ts (3 errors) ====
31+
import * as pick from 'lodash/pick';
32+
~~~~
33+
!!! error TS2440: Import declaration conflicts with local declaration of 'pick'.
34+
~~~~~~~~~~~~~
35+
!!! error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.
36+
export const pick = () => pick();
37+
~~~~
38+
!!! error TS7023: 'pick' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
39+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//// [tests/cases/compiler/conflictingDeclarationsImportFromNamespace1.ts] ////
2+
3+
//// [object.d.ts]
4+
import _ = require("./index");
5+
declare module "./index" {
6+
interface LoDashStatic {
7+
pick<T extends object, U extends keyof T>(
8+
object: T,
9+
...props: Array<U>
10+
): Pick<T, U>;
11+
}
12+
}
13+
14+
//// [pick.d.ts]
15+
import { pick } from "./index";
16+
export = pick;
17+
18+
//// [index.d.ts]
19+
/// <reference path="./object.d.ts" />
20+
export = _;
21+
export as namespace _;
22+
declare const _: _.LoDashStatic;
23+
declare namespace _ {
24+
interface LoDashStatic {}
25+
}
26+
27+
//// [index.ts]
28+
import * as pick from 'lodash/pick';
29+
export const pick = () => pick();
30+
31+
32+
//// [index.js]
33+
"use strict";
34+
Object.defineProperty(exports, "__esModule", { value: true });
35+
exports.pick = void 0;
36+
var pick = require("lodash/pick");
37+
var pick = function () { return (0, exports.pick)(); };
38+
exports.pick = pick;
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
=== tests/cases/compiler/node_modules/@types/lodash/object.d.ts ===
2+
import _ = require("./index");
3+
>_ : Symbol(_, Decl(object.d.ts, 0, 0))
4+
5+
declare module "./index" {
6+
>"./index" : Symbol(_, Decl(index.d.ts, 3, 13), Decl(index.d.ts, 3, 32), Decl(object.d.ts, 0, 30))
7+
8+
interface LoDashStatic {
9+
>LoDashStatic : Symbol(LoDashStatic, Decl(index.d.ts, 4, 21), Decl(object.d.ts, 1, 26))
10+
11+
pick<T extends object, U extends keyof T>(
12+
>pick : Symbol(LoDashStatic.pick, Decl(object.d.ts, 2, 28))
13+
>T : Symbol(T, Decl(object.d.ts, 3, 11))
14+
>U : Symbol(U, Decl(object.d.ts, 3, 28))
15+
>T : Symbol(T, Decl(object.d.ts, 3, 11))
16+
17+
object: T,
18+
>object : Symbol(object, Decl(object.d.ts, 3, 48))
19+
>T : Symbol(T, Decl(object.d.ts, 3, 11))
20+
21+
...props: Array<U>
22+
>props : Symbol(props, Decl(object.d.ts, 4, 18))
23+
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
24+
>U : Symbol(U, Decl(object.d.ts, 3, 28))
25+
26+
): Pick<T, U>;
27+
>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --))
28+
>T : Symbol(T, Decl(object.d.ts, 3, 11))
29+
>U : Symbol(U, Decl(object.d.ts, 3, 28))
30+
}
31+
}
32+
33+
=== tests/cases/compiler/node_modules/@types/lodash/pick.d.ts ===
34+
import { pick } from "./index";
35+
>pick : Symbol(pick, Decl(pick.d.ts, 0, 8))
36+
37+
export = pick;
38+
>pick : Symbol(pick, Decl(pick.d.ts, 0, 8))
39+
40+
=== tests/cases/compiler/node_modules/@types/lodash/index.d.ts ===
41+
/// <reference path="./object.d.ts" />
42+
export = _;
43+
>_ : Symbol(_, Decl(index.d.ts, 3, 13), Decl(index.d.ts, 3, 32), Decl(object.d.ts, 0, 30))
44+
45+
export as namespace _;
46+
>_ : Symbol(_, Decl(index.d.ts, 1, 11))
47+
48+
declare const _: _.LoDashStatic;
49+
>_ : Symbol(_, Decl(index.d.ts, 3, 13), Decl(index.d.ts, 3, 32), Decl(object.d.ts, 0, 30))
50+
>_ : Symbol(_, Decl(index.d.ts, 3, 13), Decl(index.d.ts, 3, 32), Decl(object.d.ts, 0, 30))
51+
>LoDashStatic : Symbol(_.LoDashStatic, Decl(index.d.ts, 4, 21), Decl(object.d.ts, 1, 26))
52+
53+
declare namespace _ {
54+
>_ : Symbol(_, Decl(index.d.ts, 3, 13), Decl(index.d.ts, 3, 32), Decl(object.d.ts, 0, 30))
55+
56+
interface LoDashStatic {}
57+
>LoDashStatic : Symbol(LoDashStatic, Decl(index.d.ts, 4, 21), Decl(object.d.ts, 1, 26))
58+
}
59+
60+
=== tests/cases/compiler/index.ts ===
61+
import * as pick from 'lodash/pick';
62+
>pick : Symbol(pick, Decl(index.ts, 0, 6), Decl(index.ts, 1, 12))
63+
64+
export const pick = () => pick();
65+
>pick : Symbol(pick, Decl(index.ts, 1, 12))
66+
>pick : Symbol(pick, Decl(index.ts, 0, 6), Decl(index.ts, 1, 12))
67+
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
=== tests/cases/compiler/node_modules/@types/lodash/object.d.ts ===
2+
import _ = require("./index");
3+
>_ : _.LoDashStatic
4+
5+
declare module "./index" {
6+
>"./index" : LoDashStatic
7+
8+
interface LoDashStatic {
9+
pick<T extends object, U extends keyof T>(
10+
>pick : <T extends object, U extends keyof T>(object: T, ...props: Array<U>) => Pick<T, U>
11+
12+
object: T,
13+
>object : T
14+
15+
...props: Array<U>
16+
>props : U[]
17+
18+
): Pick<T, U>;
19+
}
20+
}
21+
22+
=== tests/cases/compiler/node_modules/@types/lodash/pick.d.ts ===
23+
import { pick } from "./index";
24+
>pick : <T extends object, U extends keyof T>(object: T, ...props: U[]) => Pick<T, U>
25+
26+
export = pick;
27+
>pick : <T extends object, U extends keyof T>(object: T, ...props: U[]) => Pick<T, U>
28+
29+
=== tests/cases/compiler/node_modules/@types/lodash/index.d.ts ===
30+
/// <reference path="./object.d.ts" />
31+
export = _;
32+
>_ : import("tests/cases/compiler/node_modules/@types/lodash/index.d.ts").LoDashStatic
33+
34+
export as namespace _;
35+
>_ : import("tests/cases/compiler/node_modules/@types/lodash/index.d.ts").LoDashStatic
36+
37+
declare const _: _.LoDashStatic;
38+
>_ : import("tests/cases/compiler/node_modules/@types/lodash/index.d.ts").LoDashStatic
39+
>_ : any
40+
41+
declare namespace _ {
42+
interface LoDashStatic {}
43+
}
44+
45+
=== tests/cases/compiler/index.ts ===
46+
import * as pick from 'lodash/pick';
47+
>pick : <T extends object, U extends keyof T>(object: T, ...props: U[]) => Pick<T, U>
48+
49+
export const pick = () => pick();
50+
>pick : () => any
51+
>() => pick() : () => any
52+
>pick() : any
53+
>pick : () => any
54+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
tests/cases/compiler/index.ts(1,13): error TS2440: Import declaration conflicts with local declaration of 'pick'.
2+
tests/cases/compiler/index.ts(1,23): error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.
3+
tests/cases/compiler/index.ts(2,14): error TS7023: 'pick' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
4+
5+
6+
==== tests/cases/compiler/node_modules/@types/lodash/object.d.ts (0 errors) ====
7+
import _ = require("./index");
8+
declare module "./index" {
9+
interface LoDashStatic {
10+
pick: <T extends object, U extends keyof T>(
11+
object: T,
12+
...props: Array<U>
13+
) => Pick<T, U>;
14+
}
15+
}
16+
17+
==== tests/cases/compiler/node_modules/@types/lodash/pick.d.ts (0 errors) ====
18+
import { pick } from "./index";
19+
export = pick;
20+
21+
==== tests/cases/compiler/node_modules/@types/lodash/index.d.ts (0 errors) ====
22+
/// <reference path="./object.d.ts" />
23+
export = _;
24+
export as namespace _;
25+
declare const _: _.LoDashStatic;
26+
declare namespace _ {
27+
interface LoDashStatic {}
28+
}
29+
30+
==== tests/cases/compiler/index.ts (3 errors) ====
31+
import * as pick from 'lodash/pick';
32+
~~~~
33+
!!! error TS2440: Import declaration conflicts with local declaration of 'pick'.
34+
~~~~~~~~~~~~~
35+
!!! error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.
36+
export const pick = () => pick();
37+
~~~~
38+
!!! error TS7023: 'pick' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
39+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//// [tests/cases/compiler/conflictingDeclarationsImportFromNamespace2.ts] ////
2+
3+
//// [object.d.ts]
4+
import _ = require("./index");
5+
declare module "./index" {
6+
interface LoDashStatic {
7+
pick: <T extends object, U extends keyof T>(
8+
object: T,
9+
...props: Array<U>
10+
) => Pick<T, U>;
11+
}
12+
}
13+
14+
//// [pick.d.ts]
15+
import { pick } from "./index";
16+
export = pick;
17+
18+
//// [index.d.ts]
19+
/// <reference path="./object.d.ts" />
20+
export = _;
21+
export as namespace _;
22+
declare const _: _.LoDashStatic;
23+
declare namespace _ {
24+
interface LoDashStatic {}
25+
}
26+
27+
//// [index.ts]
28+
import * as pick from 'lodash/pick';
29+
export const pick = () => pick();
30+
31+
32+
//// [index.js]
33+
"use strict";
34+
Object.defineProperty(exports, "__esModule", { value: true });
35+
exports.pick = void 0;
36+
var pick = require("lodash/pick");
37+
var pick = function () { return (0, exports.pick)(); };
38+
exports.pick = pick;
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
=== tests/cases/compiler/node_modules/@types/lodash/object.d.ts ===
2+
import _ = require("./index");
3+
>_ : Symbol(_, Decl(object.d.ts, 0, 0))
4+
5+
declare module "./index" {
6+
>"./index" : Symbol(_, Decl(index.d.ts, 3, 13), Decl(index.d.ts, 3, 32), Decl(object.d.ts, 0, 30))
7+
8+
interface LoDashStatic {
9+
>LoDashStatic : Symbol(LoDashStatic, Decl(index.d.ts, 4, 21), Decl(object.d.ts, 1, 26))
10+
11+
pick: <T extends object, U extends keyof T>(
12+
>pick : Symbol(LoDashStatic.pick, Decl(object.d.ts, 2, 28))
13+
>T : Symbol(T, Decl(object.d.ts, 3, 13))
14+
>U : Symbol(U, Decl(object.d.ts, 3, 30))
15+
>T : Symbol(T, Decl(object.d.ts, 3, 13))
16+
17+
object: T,
18+
>object : Symbol(object, Decl(object.d.ts, 3, 50))
19+
>T : Symbol(T, Decl(object.d.ts, 3, 13))
20+
21+
...props: Array<U>
22+
>props : Symbol(props, Decl(object.d.ts, 4, 18))
23+
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
24+
>U : Symbol(U, Decl(object.d.ts, 3, 30))
25+
26+
) => Pick<T, U>;
27+
>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --))
28+
>T : Symbol(T, Decl(object.d.ts, 3, 13))
29+
>U : Symbol(U, Decl(object.d.ts, 3, 30))
30+
}
31+
}
32+
33+
=== tests/cases/compiler/node_modules/@types/lodash/pick.d.ts ===
34+
import { pick } from "./index";
35+
>pick : Symbol(pick, Decl(pick.d.ts, 0, 8))
36+
37+
export = pick;
38+
>pick : Symbol(pick, Decl(pick.d.ts, 0, 8))
39+
40+
=== tests/cases/compiler/node_modules/@types/lodash/index.d.ts ===
41+
/// <reference path="./object.d.ts" />
42+
export = _;
43+
>_ : Symbol(_, Decl(index.d.ts, 3, 13), Decl(index.d.ts, 3, 32), Decl(object.d.ts, 0, 30))
44+
45+
export as namespace _;
46+
>_ : Symbol(_, Decl(index.d.ts, 1, 11))
47+
48+
declare const _: _.LoDashStatic;
49+
>_ : Symbol(_, Decl(index.d.ts, 3, 13), Decl(index.d.ts, 3, 32), Decl(object.d.ts, 0, 30))
50+
>_ : Symbol(_, Decl(index.d.ts, 3, 13), Decl(index.d.ts, 3, 32), Decl(object.d.ts, 0, 30))
51+
>LoDashStatic : Symbol(_.LoDashStatic, Decl(index.d.ts, 4, 21), Decl(object.d.ts, 1, 26))
52+
53+
declare namespace _ {
54+
>_ : Symbol(_, Decl(index.d.ts, 3, 13), Decl(index.d.ts, 3, 32), Decl(object.d.ts, 0, 30))
55+
56+
interface LoDashStatic {}
57+
>LoDashStatic : Symbol(LoDashStatic, Decl(index.d.ts, 4, 21), Decl(object.d.ts, 1, 26))
58+
}
59+
60+
=== tests/cases/compiler/index.ts ===
61+
import * as pick from 'lodash/pick';
62+
>pick : Symbol(pick, Decl(index.ts, 0, 6), Decl(index.ts, 1, 12))
63+
64+
export const pick = () => pick();
65+
>pick : Symbol(pick, Decl(index.ts, 1, 12))
66+
>pick : Symbol(pick, Decl(index.ts, 0, 6), Decl(index.ts, 1, 12))
67+

0 commit comments

Comments
 (0)