Skip to content

should allow use export = in .cts when module is esnext #51018

Closed

Description

Bug Report

🔎 Search Terms

🕗 Version & Regression Information

  • This is a crash
  • This changed between versions ______ and _______
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
  • I was unable to test this on prior versions because _______

⏯ Playground Link

Playground link with relevant code

💻 Code

index.cts

import { globToTree } from './index';

export = globToTree

index.ts

export function globToTree(): any {}
Object.defineProperty(globToTree, "__esModule", { value: true });
Object.defineProperty(globToTree, "globToTree", { value: globToTree });
Object.defineProperty(globToTree, "default", { value: globToTree });
export default globToTree
{
  "compilerOptions": {
    "module": "esnext",
    "target": "es2019",
    "jsx": "preserve",
    "moduleResolution": "node",
    "allowJs": false,
    "allowUmdGlobalAccess": false,
    "sourceMap": true,
    "inlineSourceMap": false,
    "inlineSources": true,
    "declaration": false,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "allowSyntheticDefaultImports": true,
    "resolveJsonModule": true,
    "strict": true,
    "strictBindCallApply": true,
    "strictNullChecks": false,
    "strictFunctionTypes": true,
    "noImplicitThis": true,
    "noImplicitOverride": true,
    "noUncheckedIndexedAccess": true,
    "noPropertyAccessFromIndexSignature": true,
    "preserveConstEnums": true,
    "forceConsistentCasingInFileNames": true,
    "incremental": true,
    "noErrorTruncation": true,
    "removeComments": false,
    "traceResolution": false,
    "newLine": "lf",
    "esModuleInterop": true,
    "importHelpers": true,
    "noFallthroughCasesInSwitch": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "skipLibCheck": true,
    "noEmit": true
  }
}

🙁 Actual behavior

show error

image

or use @ts-ignore avoid it

import { globToTree } from './index';

// @ts-ignore
export = globToTree

🙂 Expected behavior

no need @ts-ignore

Activity

  1. RyanCavanaugh commented on Oct 7, 2022

    @RyanCavanaugh
    Member

    What code is supposed to be generated in this case?

  2. RyanCavanaugh commented on Oct 7, 2022

    @RyanCavanaugh
    Member

    https://github.com/bluelovers/ws-glob/blob/master/packages/glob-tree-list/dist/index.esm.mjs - this is just a default export, like it's telling you to do. export = (a function doesn't make sense in an ES Module output format. What's the motivation for not writing export default globToTree ?

  3. fatcerberus commented on Oct 11, 2022

    @fatcerberus

    Ryan Cavanaugh (@RyanCavanaugh) I guess they’re expecting the .cts file to compile to CommonJS instead of ESM?

  4. added
    Needs InvestigationThis issue needs a team member to investigate its status.
    and removed
    Needs More InfoThe issue still hasn't been fully clarified
    on Aug 8, 2024
  5. added
    BugA bug in TypeScript
    and removed
    Needs InvestigationThis issue needs a team member to investigate its status.
    on Aug 8, 2024
  6. andrewbranch commented on Aug 8, 2024

    @andrewbranch
    Member

    This was implemented as a new feature in 5.6 (#58825)

  7. locked as resolved and limited conversation to collaborators on Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions