fix: TS errors on dependent projects with certain tsconfig settings (#6360) (#6361)

* fix: TS errors on dependent projects with certain tsconfig settings (#6360)

* Address PR comments
This commit is contained in:
ktbytechibong
2022-09-06 16:19:56 -04:00
committed by GitHub
parent 2bf1182534
commit e58cf77b7f
3 changed files with 25 additions and 33 deletions

View File

@@ -417,20 +417,18 @@ function addAttributes(node: Node, obj: AnyDuringMigration) {
*/
export function parseToolboxTree(toolboxDef: Element|null|string): Element|
null {
let parsedToolboxDef: Element|null = null;
if (toolboxDef) {
if (typeof toolboxDef !== 'string' && !(toolboxDef instanceof Element)) {
toolboxDef = null;
}
if (typeof toolboxDef === 'string') {
toolboxDef = Xml.textToDom(toolboxDef);
if (toolboxDef.nodeName.toLowerCase() !== 'xml') {
parsedToolboxDef = Xml.textToDom(toolboxDef);
if (parsedToolboxDef.nodeName.toLowerCase() !== 'xml') {
throw TypeError('Toolbox should be an <xml> document.');
}
} else if (toolboxDef instanceof Element) {
parsedToolboxDef = toolboxDef;
}
} else {
toolboxDef = null;
}
return toolboxDef;
return parsedToolboxDef;
}
export const TEST_ONLY = {