Skip to content

Conversation

haoqixu
Copy link
Contributor

@haoqixu haoqixu commented Mar 14, 2025

  • convertJsonOption prematurely verified enum options via isCompilerOptionsValue, bypassing convertJsonOptionOfEnumType and returning string keys instead of proper enum values.

  • In parseOwnConfigOfJsonSourceFile, onPropertySet maps the string key from convertJsonOption 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 with tsc by fixing convertJsonOption and removing the conversion from onPropertySet.

} else {
return convertJsonOption(opt.Elements(), value, basePath, propertyAssignment, valueExpression, sourceFile)
}
} else if !(reflect.TypeOf(optType).Kind() == reflect.String) {
Copy link
Contributor Author

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.

Copy link
Contributor Author

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

@haoqixu haoqixu requested a review from jakebailey March 15, 2025 21:27
@haoqixu haoqixu changed the title Align error for invalid enum option with strada Fix parsing of enum options Mar 17, 2025
@jakebailey jakebailey added this pull request to the merge queue Mar 18, 2025
Merged via the queue into microsoft:main with commit 368a8e5 Mar 18, 2025
21 checks passed
zshannon pushed a commit to zshannon/typescript-go that referenced this pull request Oct 6, 2025
zshannon pushed a commit to zshannon/typescript-go that referenced this pull request Oct 6, 2025
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.

4 participants