fix: declare getMetaDataSymbol() as returning symbol | string
This commit is contained in:
1 parent
06226be0a8
commit
33b9effab3
3 files changed
+14
-2
No files matched your search
@@ -41,6 +41,18 @@ const parsed = parser.parse(XML);
|
||||
|
||||
console.log(!!parsed);
|
||||
|
||||
// The metadata key indexes parsed nodes, so it has to be a primitive property key, not a boxed `Symbol`.
|
||||
const metaDataKey: PropertyKey = XMLParser.getMetaDataSymbol();
|
||||
const metaDataNode = new XMLParser({ captureMetaData: true }).parse(XML).SomeElement;
|
||||
|
||||
console.log(metaDataNode[metaDataKey], metaDataNode[XMLParser.getMetaDataSymbol()]);
|
||||
|
||||
// Without `Symbol` in the environment the key falls back to a plain property name.
|
||||
type StringKeyAccepted = string extends ReturnType<typeof XMLParser.getMetaDataSymbol> ? true : false;
|
||||
const stringKeyAccepted: StringKeyAccepted = true;
|
||||
|
||||
console.log(stringKeyAccepted);
|
||||
|
||||
const buildOpts: XmlBuilderOptions = {};
|
||||
|
||||
const builder = new XMLBuilder(buildOpts);
|
||||
|
||||
Reference in new issue
Block a user