diff --git a/internal/tsoptions/parsinghelpers.go b/internal/tsoptions/parsinghelpers.go index 452883e37d..a527c391cb 100644 --- a/internal/tsoptions/parsinghelpers.go +++ b/internal/tsoptions/parsinghelpers.go @@ -143,6 +143,8 @@ func ParseCompilerOptions(key string, value any, allOptions *core.CompilerOption switch key { case "allowJs": allOptions.AllowJs = parseTristate(value) + case "allowImportingTsExtensions": + allOptions.AllowImportingTsExtensions = parseTristate(value) case "allowSyntheticDefaultImports": allOptions.AllowSyntheticDefaultImports = parseTristate(value) case "allowNonTsExtensions": @@ -185,6 +187,12 @@ func ParseCompilerOptions(key string, value any, allOptions *core.CompilerOption allOptions.DeclarationMap = parseTristate(value) case "declaration": allOptions.Declaration = parseTristate(value) + case "downlevelIteration": + allOptions.DownlevelIteration = parseTristate(value) + case "emitDeclarationOnly": + allOptions.EmitDeclarationOnly = parseTristate(value) + case "eSModuleInterop": + allOptions.ESModuleInterop = parseTristate(value) case "extendedDiagnostics": allOptions.ExtendedDiagnostics = parseTristate(value) case "emitDecoratorMetadata": @@ -261,6 +269,8 @@ func ParseCompilerOptions(key string, value any, allOptions *core.CompilerOption allOptions.NoFallthroughCasesInSwitch = parseTristate(value) case "noEmitForJsFiles": allOptions.NoEmitForJsFiles = parseTristate(value) + case "noErrorTruncation": + allOptions.NoErrorTruncation = parseTristate(value) case "noImplicitAny": allOptions.NoImplicitAny = parseTristate(value) case "noImplicitThis": @@ -311,6 +321,8 @@ func ParseCompilerOptions(key string, value any, allOptions *core.CompilerOption allOptions.ResolvePackageJsonImports = parseTristate(value) case "reactNamespace": allOptions.ReactNamespace = parseString(value) + case "rewriteRelativeImportExtensions": + allOptions.RewriteRelativeImportExtensions = parseTristate(value) case "rootDir": allOptions.RootDir = parseString(value) case "rootDirs": diff --git a/internal/tsoptions/parsinghelpers_test.go b/internal/tsoptions/parsinghelpers_test.go new file mode 100644 index 0000000000..f80879d5ff --- /dev/null +++ b/internal/tsoptions/parsinghelpers_test.go @@ -0,0 +1,36 @@ +package tsoptions + +import ( + "github.com/microsoft/typescript-go/internal/core" + "reflect" + "testing" + "unicode" +) + +func TestParseCompilerOptions_noMissingTristates(t *testing.T) { + var missingKeys []string + + for _, field := range reflect.VisibleFields(reflect.TypeFor[core.CompilerOptions]()) { + // The key name in ParseCompilerOptions has the first rune in lowercase + r := []rune(field.Name) + r[0] = unicode.ToLower(r[0]) + keyName := string(r) + + isTristate := field.Type == reflect.TypeFor[core.Tristate]() + if isTristate { + // Set the field on a CompilerOptions to something other than the + // default (i.e. TSTrue != TSUnknown), then check whether + // ParseCompilerOptions does actually update the value for that key. + testValue := core.TSTrue + co := core.CompilerOptions{} + ParseCompilerOptions(keyName, testValue, &co) + newSetValue := reflect.ValueOf(co).FieldByName(field.Name) + if !newSetValue.Equal(reflect.ValueOf(testValue)) { + missingKeys = append(missingKeys, keyName) + } + } + } + if len(missingKeys) > 0 { + t.Errorf("The following Tristate keys are missing entries in the ParseCompilerOptions switch statement:\n%v", missingKeys) + } +}