typescript-go icon indicating copy to clipboard operation
typescript-go copied to clipboard

Named import against CJS file with `module.exports = { ... }` errors only with tsgo

Open sapphi-red opened this issue 2 months ago • 1 comments

Steps to reproduce

  1. Clone https://github.com/sapphi-red-repros/typescript-go-cjs-named-import-behavior-difference
  2. Run pnpm i
  3. Run pnpm tsc and pnpm tsgo

Behavior with [email protected]

No error

Behavior with tsgo

foo.ts:1:19 - error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'allowSyntheticDefaultImports' flag and referencing its default export.

1 import { a } from './bar.cjs'
                    ~~~~~~~~~~~

sapphi-red avatar Oct 25 '25 18:10 sapphi-red

It seems this happens with the following code as well:

import { Token } from 'js-tokens';

export type Foo = Token

sapphi-red avatar Oct 25 '25 18:10 sapphi-red