diff --git a/src/Attributes/TypeScriptEnumNative.php b/src/Attributes/TypeScriptEnumNative.php new file mode 100644 index 00000000..c1a4a219 --- /dev/null +++ b/src/Attributes/TypeScriptEnumNative.php @@ -0,0 +1,10 @@ +config->shouldTransformToNativeEnums() + return $this->shouldTransformToNativeEnum($class) ? $this->toEnum($enum, $name) : $this->toType($enum, $name); } + protected function shouldTransformToNativeEnum(ReflectionClass $class): bool + { + $attributes = $class->getAttributes(); + + foreach ($attributes as $attribute) { + if ($attribute->getName() === TypeScriptEnumNative::class) { + return true; + } + + if ($attribute->getName() === TypeScriptEnumUnion::class) { + return false; + } + } + + return $this->config->shouldTransformToNativeEnums(); + } + protected function toEnum(ReflectionEnum $enum, string $name): TransformedType { $options = array_map(