Skip to content

[ScriptUI] reference enums with typeof to access enum properties #148

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fartinmartin
Copy link
Contributor

@fartinmartin fartinmartin commented May 17, 2025

The following lines work in ExtendScript, but will cause TypeScript to complain with (ts 2339):

ScriptUI.Alignment.LEFT // Property 'LEFT' does not exist on type '_Alignment'. 
ScriptUI.FontStyle.BOLD // Property 'BOLD' does not exist on type '_FontStyle'.
ScriptUIGraphics.PenType.SOLID_COLOR // Property 'SOLID_COLOR' does not exist on type '_BrushOrPenType'.

This is because in order to access the enum properties we need to reference their types via typeof. This PR adds this:

declare class ScriptUI {
  static readonly Alignment: typeof _Alignment
  static readonly FontStyle: typeof _FontStyle
}

declare class ScriptUIGraphics {
  static readonly BrushType: typeof _BrushOrPenType
  static readonly PenType: typeof _BrushOrPenType
}

@fartinmartin fartinmartin changed the title [ScriptUI] reference enums with typeof to properly access enum values [ScriptUI] reference enums with typeof to access enum properties May 17, 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.

1 participant