Skip to content

Fixed crash in checkExportsOnMergedDeclarationsWorker #52740

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
3 changes: 3 additions & 0 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38808,6 +38808,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
// all of which are pretty much always values, or at least imply a value meaning.
// It may be apprpriate to treat these as aliases in the future.
return DeclarationSpaces.ExportValue;
case SyntaxKind.MethodSignature:
case SyntaxKind.PropertySignature:
return DeclarationSpaces.ExportType;
default:
return Debug.failBadSyntaxKind(d);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
tests/cases/compiler/index.ts(1,13): error TS2440: Import declaration conflicts with local declaration of 'pick'.
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.
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.


==== tests/cases/compiler/node_modules/@types/lodash/object.d.ts (0 errors) ====
import _ = require("./index");
declare module "./index" {
interface LoDashStatic {
pick<T extends object, U extends keyof T>(
object: T,
...props: Array<U>
): Pick<T, U>;
}
}

==== tests/cases/compiler/node_modules/@types/lodash/pick.d.ts (0 errors) ====
import { pick } from "./index";
export = pick;

==== tests/cases/compiler/node_modules/@types/lodash/index.d.ts (0 errors) ====
/// <reference path="./object.d.ts" />
export = _;
export as namespace _;
declare const _: _.LoDashStatic;
declare namespace _ {
interface LoDashStatic {}
}

==== tests/cases/compiler/index.ts (3 errors) ====
import * as pick from 'lodash/pick';
~~~~
!!! error TS2440: Import declaration conflicts with local declaration of 'pick'.
~~~~~~~~~~~~~
!!! error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.
export const pick = () => pick();
~~~~
!!! 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.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//// [tests/cases/compiler/conflictingDeclarationsImportFromNamespace1.ts] ////

//// [object.d.ts]
import _ = require("./index");
declare module "./index" {
interface LoDashStatic {
pick<T extends object, U extends keyof T>(
object: T,
...props: Array<U>
): Pick<T, U>;
}
}

//// [pick.d.ts]
import { pick } from "./index";
export = pick;

//// [index.d.ts]
/// <reference path="./object.d.ts" />
export = _;
export as namespace _;
declare const _: _.LoDashStatic;
declare namespace _ {
interface LoDashStatic {}
}

//// [index.ts]
import * as pick from 'lodash/pick';
export const pick = () => pick();


//// [index.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.pick = void 0;
var pick = require("lodash/pick");
var pick = function () { return (0, exports.pick)(); };
exports.pick = pick;
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
=== tests/cases/compiler/node_modules/@types/lodash/object.d.ts ===
import _ = require("./index");
>_ : Symbol(_, Decl(object.d.ts, 0, 0))

declare module "./index" {
>"./index" : Symbol(_, Decl(index.d.ts, 3, 13), Decl(index.d.ts, 3, 32), Decl(object.d.ts, 0, 30))

interface LoDashStatic {
>LoDashStatic : Symbol(LoDashStatic, Decl(index.d.ts, 4, 21), Decl(object.d.ts, 1, 26))

pick<T extends object, U extends keyof T>(
>pick : Symbol(LoDashStatic.pick, Decl(object.d.ts, 2, 28))
>T : Symbol(T, Decl(object.d.ts, 3, 11))
>U : Symbol(U, Decl(object.d.ts, 3, 28))
>T : Symbol(T, Decl(object.d.ts, 3, 11))

object: T,
>object : Symbol(object, Decl(object.d.ts, 3, 48))
>T : Symbol(T, Decl(object.d.ts, 3, 11))

...props: Array<U>
>props : Symbol(props, Decl(object.d.ts, 4, 18))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>U : Symbol(U, Decl(object.d.ts, 3, 28))

): Pick<T, U>;
>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --))
>T : Symbol(T, Decl(object.d.ts, 3, 11))
>U : Symbol(U, Decl(object.d.ts, 3, 28))
}
}

=== tests/cases/compiler/node_modules/@types/lodash/pick.d.ts ===
import { pick } from "./index";
>pick : Symbol(pick, Decl(pick.d.ts, 0, 8))

export = pick;
>pick : Symbol(pick, Decl(pick.d.ts, 0, 8))

=== tests/cases/compiler/node_modules/@types/lodash/index.d.ts ===
/// <reference path="./object.d.ts" />
export = _;
>_ : Symbol(_, Decl(index.d.ts, 3, 13), Decl(index.d.ts, 3, 32), Decl(object.d.ts, 0, 30))

export as namespace _;
>_ : Symbol(_, Decl(index.d.ts, 1, 11))

declare const _: _.LoDashStatic;
>_ : Symbol(_, Decl(index.d.ts, 3, 13), Decl(index.d.ts, 3, 32), Decl(object.d.ts, 0, 30))
>_ : Symbol(_, Decl(index.d.ts, 3, 13), Decl(index.d.ts, 3, 32), Decl(object.d.ts, 0, 30))
>LoDashStatic : Symbol(_.LoDashStatic, Decl(index.d.ts, 4, 21), Decl(object.d.ts, 1, 26))

declare namespace _ {
>_ : Symbol(_, Decl(index.d.ts, 3, 13), Decl(index.d.ts, 3, 32), Decl(object.d.ts, 0, 30))

interface LoDashStatic {}
>LoDashStatic : Symbol(LoDashStatic, Decl(index.d.ts, 4, 21), Decl(object.d.ts, 1, 26))
}

=== tests/cases/compiler/index.ts ===
import * as pick from 'lodash/pick';
>pick : Symbol(pick, Decl(index.ts, 0, 6), Decl(index.ts, 1, 12))

export const pick = () => pick();
>pick : Symbol(pick, Decl(index.ts, 1, 12))
>pick : Symbol(pick, Decl(index.ts, 0, 6), Decl(index.ts, 1, 12))

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
=== tests/cases/compiler/node_modules/@types/lodash/object.d.ts ===
import _ = require("./index");
>_ : _.LoDashStatic

declare module "./index" {
>"./index" : LoDashStatic

interface LoDashStatic {
pick<T extends object, U extends keyof T>(
>pick : <T extends object, U extends keyof T>(object: T, ...props: Array<U>) => Pick<T, U>

object: T,
>object : T

...props: Array<U>
>props : U[]

): Pick<T, U>;
}
}

=== tests/cases/compiler/node_modules/@types/lodash/pick.d.ts ===
import { pick } from "./index";
>pick : <T extends object, U extends keyof T>(object: T, ...props: U[]) => Pick<T, U>

export = pick;
>pick : <T extends object, U extends keyof T>(object: T, ...props: U[]) => Pick<T, U>

=== tests/cases/compiler/node_modules/@types/lodash/index.d.ts ===
/// <reference path="./object.d.ts" />
export = _;
>_ : import("tests/cases/compiler/node_modules/@types/lodash/index.d.ts").LoDashStatic

export as namespace _;
>_ : import("tests/cases/compiler/node_modules/@types/lodash/index.d.ts").LoDashStatic

declare const _: _.LoDashStatic;
>_ : import("tests/cases/compiler/node_modules/@types/lodash/index.d.ts").LoDashStatic
>_ : any

declare namespace _ {
interface LoDashStatic {}
}

=== tests/cases/compiler/index.ts ===
import * as pick from 'lodash/pick';
>pick : <T extends object, U extends keyof T>(object: T, ...props: U[]) => Pick<T, U>

export const pick = () => pick();
>pick : () => any
>() => pick() : () => any
>pick() : any
>pick : () => any

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
tests/cases/compiler/index.ts(1,13): error TS2440: Import declaration conflicts with local declaration of 'pick'.
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.
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.


==== tests/cases/compiler/node_modules/@types/lodash/object.d.ts (0 errors) ====
import _ = require("./index");
declare module "./index" {
interface LoDashStatic {
pick: <T extends object, U extends keyof T>(
object: T,
...props: Array<U>
) => Pick<T, U>;
}
}

==== tests/cases/compiler/node_modules/@types/lodash/pick.d.ts (0 errors) ====
import { pick } from "./index";
export = pick;

==== tests/cases/compiler/node_modules/@types/lodash/index.d.ts (0 errors) ====
/// <reference path="./object.d.ts" />
export = _;
export as namespace _;
declare const _: _.LoDashStatic;
declare namespace _ {
interface LoDashStatic {}
}

==== tests/cases/compiler/index.ts (3 errors) ====
import * as pick from 'lodash/pick';
~~~~
!!! error TS2440: Import declaration conflicts with local declaration of 'pick'.
~~~~~~~~~~~~~
!!! error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.
export const pick = () => pick();
~~~~
!!! 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.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//// [tests/cases/compiler/conflictingDeclarationsImportFromNamespace2.ts] ////

//// [object.d.ts]
import _ = require("./index");
declare module "./index" {
interface LoDashStatic {
pick: <T extends object, U extends keyof T>(
object: T,
...props: Array<U>
) => Pick<T, U>;
}
}

//// [pick.d.ts]
import { pick } from "./index";
export = pick;

//// [index.d.ts]
/// <reference path="./object.d.ts" />
export = _;
export as namespace _;
declare const _: _.LoDashStatic;
declare namespace _ {
interface LoDashStatic {}
}

//// [index.ts]
import * as pick from 'lodash/pick';
export const pick = () => pick();


//// [index.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.pick = void 0;
var pick = require("lodash/pick");
var pick = function () { return (0, exports.pick)(); };
exports.pick = pick;
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
=== tests/cases/compiler/node_modules/@types/lodash/object.d.ts ===
import _ = require("./index");
>_ : Symbol(_, Decl(object.d.ts, 0, 0))

declare module "./index" {
>"./index" : Symbol(_, Decl(index.d.ts, 3, 13), Decl(index.d.ts, 3, 32), Decl(object.d.ts, 0, 30))

interface LoDashStatic {
>LoDashStatic : Symbol(LoDashStatic, Decl(index.d.ts, 4, 21), Decl(object.d.ts, 1, 26))

pick: <T extends object, U extends keyof T>(
>pick : Symbol(LoDashStatic.pick, Decl(object.d.ts, 2, 28))
>T : Symbol(T, Decl(object.d.ts, 3, 13))
>U : Symbol(U, Decl(object.d.ts, 3, 30))
>T : Symbol(T, Decl(object.d.ts, 3, 13))

object: T,
>object : Symbol(object, Decl(object.d.ts, 3, 50))
>T : Symbol(T, Decl(object.d.ts, 3, 13))

...props: Array<U>
>props : Symbol(props, Decl(object.d.ts, 4, 18))
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>U : Symbol(U, Decl(object.d.ts, 3, 30))

) => Pick<T, U>;
>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --))
>T : Symbol(T, Decl(object.d.ts, 3, 13))
>U : Symbol(U, Decl(object.d.ts, 3, 30))
}
}

=== tests/cases/compiler/node_modules/@types/lodash/pick.d.ts ===
import { pick } from "./index";
>pick : Symbol(pick, Decl(pick.d.ts, 0, 8))

export = pick;
>pick : Symbol(pick, Decl(pick.d.ts, 0, 8))

=== tests/cases/compiler/node_modules/@types/lodash/index.d.ts ===
/// <reference path="./object.d.ts" />
export = _;
>_ : Symbol(_, Decl(index.d.ts, 3, 13), Decl(index.d.ts, 3, 32), Decl(object.d.ts, 0, 30))

export as namespace _;
>_ : Symbol(_, Decl(index.d.ts, 1, 11))

declare const _: _.LoDashStatic;
>_ : Symbol(_, Decl(index.d.ts, 3, 13), Decl(index.d.ts, 3, 32), Decl(object.d.ts, 0, 30))
>_ : Symbol(_, Decl(index.d.ts, 3, 13), Decl(index.d.ts, 3, 32), Decl(object.d.ts, 0, 30))
>LoDashStatic : Symbol(_.LoDashStatic, Decl(index.d.ts, 4, 21), Decl(object.d.ts, 1, 26))

declare namespace _ {
>_ : Symbol(_, Decl(index.d.ts, 3, 13), Decl(index.d.ts, 3, 32), Decl(object.d.ts, 0, 30))

interface LoDashStatic {}
>LoDashStatic : Symbol(LoDashStatic, Decl(index.d.ts, 4, 21), Decl(object.d.ts, 1, 26))
}

=== tests/cases/compiler/index.ts ===
import * as pick from 'lodash/pick';
>pick : Symbol(pick, Decl(index.ts, 0, 6), Decl(index.ts, 1, 12))

export const pick = () => pick();
>pick : Symbol(pick, Decl(index.ts, 1, 12))
>pick : Symbol(pick, Decl(index.ts, 0, 6), Decl(index.ts, 1, 12))

Loading