Skip to content

Unable to access properties of namespace from imported package when moduleResolution: 'NodeNext'Β #49298

@ifiokjr

Description

@ifiokjr

Bug Report

πŸ”Ž Search Terms

  • moduleResolution
  • NodeNext
  • module
  • mts

πŸ•— Version & Regression Information

  • This changed between versions 4.6.4 and 4.7.2 as a result of the new "moduleResolution": "NodeNext" setting I have also tested in nightly

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

import is from '@sindresorhus/is';

is.nullOrUndefined('something');
// => Property 'nullOrUndefined' does not exist on type 'typeof import("file:///node_modules/@sindresorhus/is/dist/index")

is.emptyObject({});
// => Property 'emptyObject' does not exist on type 'typeof import("file:///node_modules/@sindresorhus/is/dist/index")'.

πŸ”§ Settings

{
  "compilerOptions": {
    "module": "ESNext",
    "target": "ESNext",
    "moduleResolution": "NodeNext", // This is the change that caused the issue.
    "jsx": "preserve",
    "lib": ["DOM", "ESNext"],
    "noImplicitReturns": true,
    "sourceMap": true,
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "noFallthroughCasesInSwitch": true,
    "forceConsistentCasingInFileNames": true,
    "allowUnreachableCode": false,
    "strict": true,
    "resolveJsonModule": true,
    "useDefineForClassFields": true,
    "importsNotUsedAsValues": "remove",
    "noUncheckedIndexedAccess": true,
    "noImplicitOverride": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "pretty": true
  }
}

πŸ™ Actual behavior

Importing from this module which exports the namespace is as its default export doesn't recognize any of the properties within the namespace.

πŸ™‚ Expected behavior

It should allow for access to the members of the namespace.

Metadata

Metadata

Assignees

Labels

DocsThe issue relates to how you learn TypeScriptDomain: Node ESMLike ES Modules, but specific to Node.js support (cts, cts, mjs, mts)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions