Open joachimvh opened 2 years ago
I think this is correct though. Since you provide a default value, this param is optional for TS. Therefore, the generator also sees it as optional, hence the union with undefined.
The problem is that this causes Components.js not to parse the config as any JSON object anymore. It complains about the fields in the JSON to be undefined URIs.
Ah, then it may be a bug during context generation. Could you check if your context contains @type: @json
for your param?
It does not:
"YargsCliExtractor": {
"@id": "scs:dist/init/cli/YargsCliExtractor.jsonld#YargsCliExtractor",
"@prefix": true,
"@context": {
"parameters": {
"@id": "scs:dist/init/cli/YargsCliExtractor.jsonld#YargsCliExtractor_parameters"
},
"options": {
"@id": "scs:dist/init/cli/YargsCliExtractor.jsonld#YargsCliExtractor_options"
}
}
},
Aha! So there's probably going something wrong here: https://github.com/LinkedSoftwareDependencies/Components-Generator.js/blob/feature/strict-type-checking/lib/serialize/ComponentConstructor.ts#L642-L655
No, scratch that, this is the correct place: https://github.com/LinkedSoftwareDependencies/Components-Generator.js/blob/feature/strict-type-checking/lib/serialize/ContextConstructor.ts#L72-L81
But the earlier link already shows a possible fix :-)
Using version
3.0.0-beta.7
Generates the following JSON-LD (same for both parameters):
Should just be
rdf:JSON
instead of the union.