Skip to content

esModuleInterop is ignored when using project references #36144

@cyberalien

Description

@cyberalien

TypeScript Version: 3.8.0-dev.20200111

Search Terms: "esModuleInterop", "esModuleInterop composite", "esModuleInterop project"

Code
Repository with short test case: https://github.com/cyberalien/typescript_esmoduleinterop_bug

Root tsconfig.json includes 2 projects: src/tsconfig.json and tests/tsconfig.json
Flag esModuleInterop is enabled in src/tsconfig.json and tests/tsconfig.json

However when running tsc -b, it throws error that esModuleInterop is not enabled.

Expected behavior:
Test case should compile without issues.

Actual behavior:
tsc throws following error:

src/get_uri.ts:1:8 - error TS1259: Module '"node_modules/@types/request/index"' can only be default-imported using the 'esModuleInterop' flag

1 import request, { Response } from 'request';
         ~~~~~~~

  node_modules/@types/request/index.d.ts:405:1
    405 export = request;
        ~~~~~~~~~~~~~~~~~
    This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.


Found 1 error.

Workaround:
Workaround to demonstrate that this is compiler issue, not code issue: to root tsconfig.json add this:

	"compilerOptions": {
		"composite": true,
		"esModuleInterop": true,
		"noEmit": true
	},

(see tsconfig-workaround.json in repository)

Then esModuleInterop becomes enabled in referenced projects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions