Skip to content
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

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

Closed
bluelovers opened this issue Sep 30, 2022 · 5 comments
Closed

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

bluelovers opened this issue Sep 30, 2022 · 5 comments
Assignees

Comments

@bluelovers
Copy link
Contributor

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

@RyanCavanaugh
Copy link
Member

What code is supposed to be generated in this case?

@RyanCavanaugh RyanCavanaugh added the Needs More Info The issue still hasn't been fully clarified label Oct 7, 2022
@RyanCavanaugh
Copy link
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 ?

@fatcerberus
Copy link

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

@RyanCavanaugh RyanCavanaugh added Needs Investigation This issue needs a team member to investigate its status. and removed Needs More Info The issue still hasn't been fully clarified labels Aug 8, 2024
@andrewbranch andrewbranch added Bug A bug in TypeScript and removed Needs Investigation This issue needs a team member to investigate its status. labels Aug 8, 2024
@andrewbranch andrewbranch added this to the TypeScript 5.6.1 milestone Aug 8, 2024
@andrewbranch andrewbranch removed the Bug A bug in TypeScript label Aug 8, 2024
@andrewbranch
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants