From f0e24c227cd9c8506dc79870c9fbba109a5d0501 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Tue, 28 Oct 2025 22:40:05 -0700 Subject: [PATCH] Fix various named enum types --- internal/ast/parseoptions.go | 2 +- internal/ast/subtreefacts.go | 2 +- internal/checker/types.go | 2 +- internal/module/resolver_test.go | 6 +++--- internal/nodebuilder/types.go | 2 +- internal/parser/parser_test.go | 4 ++-- internal/parser/testdata/fuzz/FuzzParser/02b74efe61495c2a | 4 ++-- internal/parser/testdata/fuzz/FuzzParser/9ce2d994c65c7bfe | 4 ++-- internal/vfs/utilities.go | 5 ++--- 9 files changed, 15 insertions(+), 16 deletions(-) diff --git a/internal/ast/parseoptions.go b/internal/ast/parseoptions.go index f464a4523d..73e8bfc6c5 100644 --- a/internal/ast/parseoptions.go +++ b/internal/ast/parseoptions.go @@ -5,7 +5,7 @@ import ( "github.com/microsoft/typescript-go/internal/tspath" ) -type JSDocParsingMode int +type JSDocParsingMode uint8 const ( JSDocParsingModeParseAll JSDocParsingMode = iota diff --git a/internal/ast/subtreefacts.go b/internal/ast/subtreefacts.go index fcd6885044..08d2ce14de 100644 --- a/internal/ast/subtreefacts.go +++ b/internal/ast/subtreefacts.go @@ -4,7 +4,7 @@ import ( "github.com/microsoft/typescript-go/internal/core" ) -type SubtreeFacts int32 +type SubtreeFacts uint32 const ( // Facts diff --git a/internal/checker/types.go b/internal/checker/types.go index 5a6066f458..dea7521017 100644 --- a/internal/checker/types.go +++ b/internal/checker/types.go @@ -82,7 +82,7 @@ const TypeFormatFlagsNodeBuilderFlagsMask = TypeFormatFlagsNoTruncation | TypeFo TypeFormatFlagsUseTypeOfFunction | TypeFormatFlagsOmitParameterModifiers | TypeFormatFlagsUseAliasDefinedOutsideCurrentScope | TypeFormatFlagsAllowUniqueESSymbolType | TypeFormatFlagsInTypeAlias | TypeFormatFlagsUseSingleQuotesForStringLiteralType | TypeFormatFlagsNoTypeReduction | TypeFormatFlagsOmitThisParameter -type SymbolFormatFlags int32 +type SymbolFormatFlags uint32 const ( SymbolFormatFlagsNone SymbolFormatFlags = 0 diff --git a/internal/module/resolver_test.go b/internal/module/resolver_test.go index eb777c8e33..37330dc8d5 100644 --- a/internal/module/resolver_test.go +++ b/internal/module/resolver_test.go @@ -211,7 +211,7 @@ type rawArgs struct { Name string `json:"name"` ContainingFile string `json:"containingFile"` CompilerOptions *core.CompilerOptions `json:"compilerOptions"` - ResolutionMode int `json:"resolutionMode"` + ResolutionMode core.ModuleKind `json:"resolutionMode"` RedirectedRef *struct { SourceFile struct { FileName string `json:"fileName"` @@ -265,7 +265,7 @@ func doCall(t *testing.T, resolver *module.Resolver, call functionCall, skipLoca errorMessageArgs := []any{call.args.Name, call.args.ContainingFile} if call.call == "resolveModuleName" { - resolved, _ := resolver.ResolveModuleName(call.args.Name, call.args.ContainingFile, core.ModuleKind(call.args.ResolutionMode), redirectedReference) + resolved, _ := resolver.ResolveModuleName(call.args.Name, call.args.ContainingFile, call.args.ResolutionMode, redirectedReference) assert.Check(t, resolved != nil, "ResolveModuleName should not return nil", errorMessageArgs) if expectedResolvedModule, ok := call.returnValue["resolvedModule"].(map[string]any); ok { assert.Check(t, resolved.IsResolved(), errorMessageArgs) @@ -277,7 +277,7 @@ func doCall(t *testing.T, resolver *module.Resolver, call functionCall, skipLoca assert.Check(t, !resolved.IsResolved(), errorMessageArgs) } } else { - resolved, _ := resolver.ResolveTypeReferenceDirective(call.args.Name, call.args.ContainingFile, core.ModuleKind(call.args.ResolutionMode), redirectedReference) + resolved, _ := resolver.ResolveTypeReferenceDirective(call.args.Name, call.args.ContainingFile, call.args.ResolutionMode, redirectedReference) assert.Check(t, resolved != nil, "ResolveTypeReferenceDirective should not return nil", errorMessageArgs) if expectedResolvedTypeReferenceDirective, ok := call.returnValue["resolvedTypeReferenceDirective"].(map[string]any); ok { assert.Check(t, resolved.IsResolved(), errorMessageArgs) diff --git a/internal/nodebuilder/types.go b/internal/nodebuilder/types.go index ab10b8c171..91d562628c 100644 --- a/internal/nodebuilder/types.go +++ b/internal/nodebuilder/types.go @@ -26,7 +26,7 @@ type SymbolTracker interface { } // NOTE: If modifying this enum, must modify `TypeFormatFlags` too! -type Flags int32 +type Flags uint32 const ( FlagsNone Flags = 0 diff --git a/internal/parser/parser_test.go b/internal/parser/parser_test.go index 4cea055265..529d257949 100644 --- a/internal/parser/parser_test.go +++ b/internal/parser/parser_test.go @@ -111,11 +111,11 @@ func FuzzParser(f *testing.F) { sourceText, err := os.ReadFile(file.path) assert.NilError(f, err) extension := tspath.TryGetExtensionFromPath(file.path) - f.Add(extension, string(sourceText), int(core.ScriptTargetESNext), int(ast.JSDocParsingModeParseAll)) + f.Add(extension, string(sourceText), int32(core.ScriptTargetESNext), uint8(ast.JSDocParsingModeParseAll)) } } - f.Fuzz(func(t *testing.T, extension string, sourceText string, scriptTarget_ int, jsdocParsingMode_ int) { + f.Fuzz(func(t *testing.T, extension string, sourceText string, scriptTarget_ int32, jsdocParsingMode_ uint8) { scriptTarget := core.ScriptTarget(scriptTarget_) jsdocParsingMode := ast.JSDocParsingMode(jsdocParsingMode_) diff --git a/internal/parser/testdata/fuzz/FuzzParser/02b74efe61495c2a b/internal/parser/testdata/fuzz/FuzzParser/02b74efe61495c2a index bcaba2fc86..6bd4a7bcdb 100644 --- a/internal/parser/testdata/fuzz/FuzzParser/02b74efe61495c2a +++ b/internal/parser/testdata/fuzz/FuzzParser/02b74efe61495c2a @@ -1,5 +1,5 @@ go test fuzz v1 string(".ts") string("/**@0\n * */0") -int(99) -int(0) +int32(99) +uint8(0) diff --git a/internal/parser/testdata/fuzz/FuzzParser/9ce2d994c65c7bfe b/internal/parser/testdata/fuzz/FuzzParser/9ce2d994c65c7bfe index c416e2e17a..7ba034ca18 100644 --- a/internal/parser/testdata/fuzz/FuzzParser/9ce2d994c65c7bfe +++ b/internal/parser/testdata/fuzz/FuzzParser/9ce2d994c65c7bfe @@ -1,5 +1,5 @@ go test fuzz v1 string(".ts") string("/") -int(99) -int(1) +int32(99) +uint8(1) diff --git a/internal/vfs/utilities.go b/internal/vfs/utilities.go index d86a7f0d10..93ceb4a0f7 100644 --- a/internal/vfs/utilities.go +++ b/internal/vfs/utilities.go @@ -314,11 +314,10 @@ var ( ) func GetRegexFromPattern(pattern string, useCaseSensitiveFileNames bool) *regexp2.Regexp { - flags := regexp2.ECMAScript + opts := regexp2.RegexOptions(regexp2.ECMAScript) if !useCaseSensitiveFileNames { - flags |= regexp2.IgnoreCase + opts |= regexp2.IgnoreCase } - opts := regexp2.RegexOptions(flags) key := regexp2CacheKey{pattern, opts}