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

cts files emitting cjs files with ES module syntax #56999

Closed
PythonCoderAS opened this issue Jan 9, 2024 · 2 comments
Closed

cts files emitting cjs files with ES module syntax #56999

PythonCoderAS opened this issue Jan 9, 2024 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@PythonCoderAS
Copy link

PythonCoderAS commented Jan 9, 2024

πŸ”Ž Search Terms

cts
cjs
.cts
.cjs

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about cts files

⏯ Playground Link

https://github.com/PythonCoderAS/typescript-bug-repro

πŸ’» Code

File config.ts:

import { resolve } from "path";

const config = resolve(__dirname, "config.cts")

module.exports = config;

πŸ™ Actual behavior

config.cjs:

import { resolve } from "path";
const config = resolve(__dirname, "config.cts");
module.exports = config;
//# sourceMappingURL=config.cjs.map

πŸ™‚ Expected behavior

const { resolve } = require("path");
const config = resolve(__dirname, "config.cts");
module.exports = config;
//# sourceMappingURL=config.cjs.map

This is correct because cjs files cannot use ESM things like import.

Additional information about the issue

This might be an error to use but it should throw an error instead of failing silently.

@RyanCavanaugh
Copy link
Member

Duplicate #50647

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jan 9, 2024
@typescript-bot
Copy link
Collaborator

This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@typescript-bot typescript-bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants