futurGH / ts-to-jsdoc

Transpile TypeScript code to fully compatible JavaScript + JSDoc comments.
MIT License
181 stars 17 forks source link

Error ERR_UNSUPPORTED_DIR_IMPORT: Directory import x is not supported resolving ES modules #20

Closed milahu closed 1 year ago

milahu commented 1 year ago

typescript input

import { SomeThing } from './some-dir';

actual javascript output: in ESM, this throws ERR_UNSUPPORTED_DIR_IMPORT

import { SomeThing } from './some-dir';

expected javascript output: resolve directory import to file import

import { SomeThing } from './some-dir/index.js';

in commonjs, the directory import would work

const { SomeThing } = require ('./some-dir');

ideally, ts-to-jsdoc would support converting an input directory, so it can resolve file paths

related issues

possible solutions

futurGH commented 1 year ago

Not planning on touching imports — I think I'm going to take the same stance as TS and say your imports in TS should be written the way you want them to appear in the output JS.