Add test and explicit typing

This commit is contained in:
Pieter Vander Vennet 2024-04-13 01:16:53 +02:00
parent df1fef28c0
commit 7eaccea1f0

View file

@ -502,6 +502,12 @@ export class AddQuestionBox extends DesugaringStep<LayerConfigJson> {
)
}
/**
* const action = new AddQuestionBox()
* const tagRenderings = [{id:"questions", render: {"*": "{questions()}" } }]
* const conv = action.convert({tagRenderings}, ConversionContext.construct(["test"], []))
* conv.tagRenderings // => [{id:"questions", render: {"*": "{questions()}" } }]
*/
convert(json: LayerConfigJson, context: ConversionContext): LayerConfigJson {
if (
json.tagRenderings === undefined ||
@ -515,7 +521,7 @@ export class AddQuestionBox extends DesugaringStep<LayerConfigJson> {
json = { ...json }
json.tagRenderings = [...json.tagRenderings]
const allSpecials: Exclude<RenderingSpecification, string>[] = <any>(
ValidationUtils.getAllSpecialVisualisations(<any>json.tagRenderings).filter(
ValidationUtils.getAllSpecialVisualisations(<QuestionableTagRenderingConfigJson[]> json.tagRenderings).filter(
(spec) => typeof spec !== "string"
)
)
@ -539,7 +545,7 @@ export class AddQuestionBox extends DesugaringStep<LayerConfigJson> {
)
)
)
const seen = new Set()
const seen: Set<string> = new Set()
for (const questionSpecial of questionSpecials) {
if (typeof questionSpecial === "string") {
continue