microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.99k stars 12.48k forks source link

Error: Debug Failure. False expression: Expected the specifier to be a default export #58044

Closed Andarist closed 6 months ago

Andarist commented 7 months ago

🔎 Search Terms

default export specifier debug failure

🕗 Version & Regression Information

⏯ Playground Link

N/A

💻 Code

/// <reference path="fourslash.ts" />

// @module: nodenext
// @allowJs: true

// @Filename: /node_modules/dom7/index.d.ts
//// export interface Dom7Array {
////   length: number;
////   prop(propName: string): any;
//// }
////
//// export interface Dom7 {
////   (): Dom7Array;
////   fn: any;
//// }
////
//// declare const Dom7: Dom7;
////
//// export {
////   Dom7 as $,
//// };

// @Filename: /dom7.js
//// import * as methods from 'dom7';
//// Object.keys(methods).forEach((methodName) => {
////   if (methodName === '$') return;
////   methods.$.fn[methodName] = methods[methodName];
//// });
////
//// export default methods.$;

// @Filename: /swipe-back.js
//// import $ from './dom7.js';
//// /*1*/

verify.completions({
    marker: "1",
    // some kind of a check should be added here
    preferences: {
        includeCompletionsForModuleExports: true,
    }
});

🙁 Actual behavior

It crashes

🙂 Expected behavior

It shouldn't crash

Additional information about the issue

repro based on https://github.com/microsoft/TypeScript/issues/58018#issuecomment-2028929028

DanielRosenwasser commented 7 months ago

Pasting in the full stack trace:

Req #2517 - completionInfo
    at /typescript-5.5.0-dev.20240331/lib/typescript.js:134906:13
    at firstDefined (/typescript-5.5.0-dev.20240331/lib/typescript.js:2373:20)
    at getNameForExportDefault (/typescript-5.5.0-dev.20240331/lib/typescript.js:134901:33)
    at getDefaultExportInfoWorker (/typescript-5.5.0-dev.20240331/lib/typescript.js:134886:16)
    at getDefaultExportInfoWorker (/typescript-5.5.0-dev.20240331/lib/typescript.js:134892:14)
    at getDefaultLikeExportInfo (/typescript-5.5.0-dev.20240331/lib/typescript.js:134868:16)
    at /typescript-5.5.0-dev.20240331/lib/typescript.js:134827:29
    at /typescript-5.5.0-dev.20240331/lib/typescript.js:134728:119
    at forEachExternalModule (/typescript-5.5.0-dev.20240331/lib/typescript.js:134789:7)
    at forEachExternalModuleToImportFrom (/typescript-5.5.0-dev.20240331/lib/typescript.js:134728:3)
    at getExportInfoMap (/typescript-5.5.0-dev.20240331/lib/typescript.js:134816:5)
    at collectAutoImports (/typescript-5.5.0-dev.20240331/lib/typescript.js:160432:24)
    at getGlobalCompletions (/typescript-5.5.0-dev.20240331/lib/typescript.js:160367:5)
    at tryGetGlobalSymbols (/typescript-5.5.0-dev.20240331/lib/typescript.js:160295:397)
    at getCompletionData (/typescript-5.5.0-dev.20240331/lib/typescript.js:160043:10)
    at Object.getCompletionsAtPosition (/typescript-5.5.0-dev.20240331/lib/typescript.js:158005:26)
    at Object.getCompletionsAtPosition2 [as getCompletionsAtPosition] (/typescript-5.5.0-dev.20240331/lib/typescript.js:145561:35)
    at IOSession.getCompletions (/typescript-5.5.0-dev.20240331/lib/typescript.js:185804:54)
    at completionInfo (/typescript-5.5.0-dev.20240331/lib/typescript.js:184194:43)
    at /typescript-5.5.0-dev.20240331/lib/typescript.js:186589:69
    at IOSession.executeWithRequestId (/typescript-5.5.0-dev.20240331/lib/typescript.js:186581:14)
    at IOSession.executeCommand (/typescript-5.5.0-dev.20240331/lib/typescript.js:186589:29)
    at IOSession.onMessage (/typescript-5.5.0-dev.20240331/lib/typescript.js:186631:51)
    at Interface.<anonymous> (/typescript-5.5.0-dev.20240331/lib/tsserver.js:504:14)