fix: robust reading of moduleResolution from tsconfig.json#361
Open
Yeggstry wants to merge 2 commits intofabien0102:mainfrom
Open
fix: robust reading of moduleResolution from tsconfig.json#361Yeggstry wants to merge 2 commits intofabien0102:mainfrom
Yeggstry wants to merge 2 commits intofabien0102:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
I came across the same issue reported in #358 - the imports generated as
from "./SchemaFile.zod"instead offrom "./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