config-loader: workaround for config schema parsing in typescript 4.3
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/config-loader': patch
|
||||
---
|
||||
|
||||
Fixed configuration schema parsing when using TypeScript `4.3`.
|
||||
@@ -168,6 +168,23 @@ function compileTsSchemas(paths: string[]) {
|
||||
},
|
||||
[path.split(sep).join('/')], // Unix paths are expected for all OSes here
|
||||
) as JsonObject | null;
|
||||
|
||||
// This is a workaround for an API change in TypeScript 4.3 where doc comments no
|
||||
// longer are represented by a single string, but instead an array of objects.
|
||||
// This isn't handled by typescript-json-schema so we do the conversion here instead.
|
||||
value = JSON.parse(JSON.stringify(value), (key, prop) => {
|
||||
if (key === 'visibility' && Array.isArray(prop)) {
|
||||
const text = prop[0]?.text;
|
||||
if (!text) {
|
||||
const propStr = JSON.stringify(prop);
|
||||
throw new Error(
|
||||
`Failed conversion of visibility schema, got ${propStr}`,
|
||||
);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
return prop;
|
||||
});
|
||||
} catch (error) {
|
||||
if (error.message !== 'type Config not found') {
|
||||
throw error;
|
||||
|
||||
Reference in New Issue
Block a user