Skip to content

Expose the *Json settings types in the @coderline/alphatab package #1576

@bali182

Description

@bali182

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

I've just installed the latest alpha (1.4.0-alpha.1080 at this point), and I'm really happy you included the JSON version of the configuration types.

The issue I'm facing, is that the types are not exposed. So while type checking/autocomplete works fine for inline api-creation:

new AlphaTabApi(dom, { ... })

The type itself cannot be reused without extracting it first:

import { AlphaTabApi } from '@coderline/alphatab'

// Get the constructor type which is a union
type Settings = ConstructorParameters<typeof AlphaTabApi>[1]
// Extract the JSON type with some ts magic
type ExtractJsonType<T> = T extends { fillFromJson: any } ? never : T
type SettingsJson = ExtractJsonType<Settings>

// Extract the necessary types from the Json type
type CoreSettingsJson = Exclude<SettingsJson['core'], undefined>
type PlayerSettingsJson = Exclude<SettingsJson['player'], undefined>
type DisplaySettingsJson = Exclude<SettingsJson['display'], undefined>

Expected Behavior

import { SettingsJson, CoreSettingsJson, DisplaySettingsJson, NotationSettingsJson, ImporterSettingsJson, PlayerSettingsJson } from '@coderline/alphatab'

or at least:

import { SettingsJson } from '@coderline/alphatab'

Steps To Reproduce

Link to jsFiddle, CodePen, Project

No response

Found in Version

1.4 (alpha)

Platform

Web

Environment

- **OS**: Win 11
- **Browser**: not relevant
- **.net Version**: not relevant

Anything else?

No response

Metadata

Metadata

Assignees

Labels

area-coreRelated to some core parts of alphaTabplatform-javascriptRelated to the JavaScript version of alphaTabstate-acceptedThis is a valid topic to work on.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions