From d605a95a163faf8cc8b497598ae0efc70fb4820b Mon Sep 17 00:00:00 2001 From: Greg Ristow Date: Mon, 21 Mar 2022 09:39:34 -0400 Subject: [PATCH] fix(staveconnector): More readable type definitions --- docs/api/classes/StaveConnector.html | 6 +++--- src/staveconnector.ts | 25 +++++++++++++++++++++---- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/docs/api/classes/StaveConnector.html b/docs/api/classes/StaveConnector.html index dbfd99b97c..fa835db02d 100644 --- a/docs/api/classes/StaveConnector.html +++ b/docs/api/classes/StaveConnector.html @@ -3,11 +3,11 @@

Hierarchy

Index

Constructors

constructor

Properties

Readonly bottom_stave

bottom_stave: Stave

Readonly thickness

thickness: number

Readonly top_stave

top_stave: Stave

Static TEXT_FONT

TEXT_FONT: Required<FontInfo> = ...

Default font for text. This is not related to music engraving. Instead, see Flow.setMusicFont(...fontNames) to customize the font for musical symbols placed on the score.

-

Static Readonly type

type: { BOLD_DOUBLE_LEFT: 5; BOLD_DOUBLE_RIGHT: 6; BRACE: 3; BRACKET: 4; DOUBLE: 2; NONE: 8; SINGLE: 1; SINGLE_LEFT: 1; SINGLE_RIGHT: 0; THIN_DOUBLE: 7 } = ...
+

Static Readonly type

type: Record<string, 0 | 2 | 1 | 3 | 4 | 5 | 6 | 7 | 8> = ...

SINGLE_LEFT and SINGLE are the same value for compatibility with older versions of vexflow which didn't have right sided stave connectors.

-

Type declaration

  • BOLD_DOUBLE_LEFT: 5
  • BOLD_DOUBLE_RIGHT: 6
  • BRACE: 3
  • BRACKET: 4
  • DOUBLE: 2
  • NONE: 8
  • SINGLE: 1
  • SINGLE_LEFT: 1
  • SINGLE_RIGHT: 0
  • THIN_DOUBLE: 7

Static Readonly typeString

typeString: { boldDoubleLeft: 5; boldDoubleRight: 6; brace: 3; bracket: 4; double: 2; none: 8; single: 1; singleLeft: 1; singleRight: 0; thinDouble: 7 } = ...
+

Static Readonly typeString

typeString: Record<"singleRight" | "singleLeft" | "single" | "double" | "brace" | "bracket" | "boldDoubleLeft" | "boldDoubleRight" | "thinDouble" | "none", 0 | 2 | 1 | 3 | 4 | 5 | 6 | 7 | 8> = ...

Connector type:

  • "singleRight"
  • @@ -21,7 +21,7 @@
  • "thinDouble"
  • "none"
-

Type declaration

  • boldDoubleLeft: 5
  • boldDoubleRight: 6
  • brace: 3
  • bracket: 4
  • double: 2
  • none: 8
  • single: 1
  • singleLeft: 1
  • singleRight: 0
  • thinDouble: 7

Accessors

font

  • get font(): string
  • set font(f: string): void
  • +

Accessors

font

  • get font(): string
  • set font(f: string): void
  • Returns the CSS compatible font string.

    Returns string

  • Provide a CSS compatible font string (e.g., 'bold 16px Arial').

    diff --git a/src/staveconnector.ts b/src/staveconnector.ts index 84ea6abe71..cd122e7a7e 100644 --- a/src/staveconnector.ts +++ b/src/staveconnector.ts @@ -34,8 +34,25 @@ function drawBoldDoubleLine(ctx: RenderContext, type: number, topX: number, topY * see {@link StaveConnector.type} & {@link StaveConnector.typeString} */ export type StaveConnectorType = - | typeof StaveConnector['type'][keyof typeof StaveConnector['type']] - | keyof typeof StaveConnector['typeString']; + | 'singleRight' + | 'singleLeft' + | 'single' + | 'double' + | 'brace' + | 'bracket' + | 'boldDoubleLeft' + | 'boldDoubleRight' + | 'thinDouble' + | 'none' + | 0 + | 1 + | 2 + | 3 + | 4 + | 5 + | 6 + | 7 + | 8; /** StaveConnector implements the connector lines between staves of a system. */ export class StaveConnector extends Element { @@ -55,7 +72,7 @@ export class StaveConnector extends Element { * with older versions of vexflow which didn't have right sided * stave connectors. */ - static readonly type = { + static readonly type: Record> = { SINGLE_RIGHT: 0, SINGLE_LEFT: 1, SINGLE: 1, @@ -81,7 +98,7 @@ export class StaveConnector extends Element { * * "thinDouble" * * "none" */ - static readonly typeString = { + static readonly typeString: Record, Exclude> = { singleRight: StaveConnector.type.SINGLE_RIGHT, singleLeft: StaveConnector.type.SINGLE_LEFT, single: StaveConnector.type.SINGLE,