CoderLine / alphaTab

alphaTab is a cross platform music notation and guitar tablature rendering library.
http://www.alphatab.net
Mozilla Public License 2.0
1.23k stars 199 forks source link

[BUG] Color type prompt in RenderingResources has error #1463

Closed Barba828 closed 4 months ago

Barba828 commented 4 months ago

Is there an existing issue for this?

Current Behavior

It works if I write this, but typescript will report an error because the colorValue is actually a string, but mainGlyphColor can only accept the type Color, and src/model/Color.ts is not exported.

display:{
  resources:{
      mainGlyphColor: "#f00",
      staffLineColor: "rgb(255, 0, 0)",
  } as RenderingResources
}

Expected Behavior

can use string

Steps To Reproduce

  1. use ts

Link to jsFiddle, CodePen, Project

No response

Found in Version

1.3-alpha

Platform

Web

Environment

- **OS**:
- **Browser**:
- **.net Version**:

Anything else?

No response

Danielku15 commented 4 months ago

There a few bits to this issue. Its not a bug but everything is as intended. Here some clarifications:

  1. The use of plain objects might lead to errors. You can "fill" the settings object from a plain javascript object via settings.fillFromJson. But you might not have some time safety you'd like to have. See here:

image https://www.alphatab.net/docs/reference/settings

  1. AlphaTab exports all objects through the main module via nested namespaces/objects.
    
    // full import with namespace access
    import * as alphaTab from '@coderline/alphatab';
    const c = new alphaTab.model.Color(255, 0, 0);

// import model import { model } from '@coderline/alphatab'; const c = new model.Color(255, 0, 0);



Hope this helps.