Skip to content

fix: robust reading of moduleResolution from tsconfig.json#361

Open
Yeggstry wants to merge 2 commits intofabien0102:mainfrom
Yeggstry:fix/parse-ts-config
Open

fix: robust reading of moduleResolution from tsconfig.json#361
Yeggstry wants to merge 2 commits intofabien0102:mainfrom
Yeggstry:fix/parse-ts-config

Conversation

@Yeggstry
Copy link

@Yeggstry Yeggstry commented Mar 18, 2026

Why

I came across the same issue reported in #358 - the imports generated as from "./SchemaFile.zod" instead of from "./SchemaFile.zod.js".

Upon investigation, this is due to the parsing of the tsconfig.json file failing silently, due to it containing comments. I confirmed this by removing the comments from my tsconfig.json file and it found my moduleResolution setting.

Since comments are common in this file (they're even there when running tsc --init), there is a safe method for parsing the config file included: ts.parseConfigFileTextToJson .

I've made the parsing of the tsconfig.json more robust overall, to also handle the scenario where module or moduleResolution (or both!) are not included in the configuration, as neither field are required but have default values for different circumstances.

Fixes #358

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

Successfully merging this pull request may close these issues.

ts error: generated import missing .js extension

1 participant