forked from MapComplete/MapComplete
Add test and explicit typing
This commit is contained in:
parent
df1fef28c0
commit
7eaccea1f0
1 changed files with 8 additions and 2 deletions
|
@ -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 {
|
convert(json: LayerConfigJson, context: ConversionContext): LayerConfigJson {
|
||||||
if (
|
if (
|
||||||
json.tagRenderings === undefined ||
|
json.tagRenderings === undefined ||
|
||||||
|
@ -515,7 +521,7 @@ export class AddQuestionBox extends DesugaringStep<LayerConfigJson> {
|
||||||
json = { ...json }
|
json = { ...json }
|
||||||
json.tagRenderings = [...json.tagRenderings]
|
json.tagRenderings = [...json.tagRenderings]
|
||||||
const allSpecials: Exclude<RenderingSpecification, string>[] = <any>(
|
const allSpecials: Exclude<RenderingSpecification, string>[] = <any>(
|
||||||
ValidationUtils.getAllSpecialVisualisations(<any>json.tagRenderings).filter(
|
ValidationUtils.getAllSpecialVisualisations(<QuestionableTagRenderingConfigJson[]> json.tagRenderings).filter(
|
||||||
(spec) => typeof spec !== "string"
|
(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) {
|
for (const questionSpecial of questionSpecials) {
|
||||||
if (typeof questionSpecial === "string") {
|
if (typeof questionSpecial === "string") {
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue