-
Notifications
You must be signed in to change notification settings - Fork 718
Fix parsing of enum options #593
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
Conversation
} else { | ||
return convertJsonOption(opt.Elements(), value, basePath, propertyAssignment, valueExpression, sourceFile) | ||
} | ||
} else if !(reflect.TypeOf(optType).Kind() == reflect.String) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strada
uses a Map as type of enum option and use !isString(opt.type)
as condition of this branch. However tsgo
use CommandLineOptionKind
for CommandLineOption.Kind
whose underlying type is string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the bug you referred to in another comment. 🤔 @jakebailey
convertJsonOption
prematurely verified enum options viaisCompilerOptionsValue
, bypassingconvertJsonOptionOfEnumType
and returning string keys instead of proper enum values.In
parseOwnConfigOfJsonSourceFile
,onPropertySet
maps the string key fromconvertJsonOption
to the appropriate enum value. However,convertJsonOptionOfListType
did not handle this translation for list elements.As a result, top-level enum options (e.g., "target") correctly use enum values in the final compiler options, but enum option lists (e.g., "lib") wrongly retain string keys. Additionally, invalid enum values trigger TS5024 errors instead of the intended TS6046.
This PR aligns
tsgo
withtsc
by fixingconvertJsonOption
and removing the conversion fromonPropertySet
.