Skip to content
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

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

Closed
1 task done
bali182 opened this issue Jul 12, 2024 · 2 comments · Fixed by #1578
Closed
1 task done

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

bali182 opened this issue Jul 12, 2024 · 2 comments · Fixed by #1578
Assignees
Labels
area-core Related to some core parts of alphaTab platform-javascript Related to the JavaScript version of alphaTab state-accepted This is a valid topic to work on.

Comments

@bali182
Copy link

bali182 commented Jul 12, 2024

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

@bali182 bali182 added the state-needs-triage Bug not triaged yet. label Jul 12, 2024
@Danielku15 Danielku15 added 🚀 type-improvement state-accepted This is a valid topic to work on. platform-javascript Related to the JavaScript version of alphaTab area-core Related to some core parts of alphaTab and removed state-needs-triage Bug not triaged yet. labels Jul 13, 2024
@Danielku15
Copy link
Member

Very good point. For the proper use they should be exposed.

@bali182
Copy link
Author

bali182 commented Jul 14, 2024

This works perfectly in 1.4.0-alpha.1085 now, thank you!

import { json } from '@coderline/alphatab'

const display: json.DisplaySettingsJson = {...}
const player: json.PlayerSettingsJson = {...}
const core: json.CoreSettingsJson = {...}

const config: json.SettingsJson = { core, display, player }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core Related to some core parts of alphaTab platform-javascript Related to the JavaScript version of alphaTab state-accepted This is a valid topic to work on.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants