Skip to content

Commit

Permalink
explicit properties in AST node constructor
Browse files Browse the repository at this point in the history
needed due to this issue:

microsoft/TypeScript#26811
  • Loading branch information
brodycj committed Aug 11, 2020
1 parent 7f23807 commit 1024b24
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions src/language-html/ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,42 @@ const NODES_KEYS = {
};

class Node {
constructor(props = {}) {
for (const key of Object.keys(props)) {
const value = props[key];
constructor({
// eslint-disable-next-line unicorn/no-useless-undefined
index = undefined,
// eslint-disable-next-line unicorn/no-useless-undefined
siblings = undefined,
// eslint-disable-next-line unicorn/no-useless-undefined
prev = undefined,
// eslint-disable-next-line unicorn/no-useless-undefined
next = undefined,
// eslint-disable-next-line unicorn/no-useless-undefined
parent = undefined,
// eslint-disable-next-line unicorn/no-useless-undefined
hasExplicitNamespace = undefined,
// eslint-disable-next-line unicorn/no-useless-undefined
name = undefined,
// eslint-disable-next-line unicorn/no-useless-undefined
namespace = undefined,
// eslint-disable-next-line unicorn/no-useless-undefined
children = undefined,
...opts
} = {}) {
// explicit properties needed here due to:
// https://github.com/microsoft/TypeScript/issues/26811
this.index = index;
this.siblings = siblings;
this.prev = prev;
this.next = next;
this.parent = parent;
this.hasExplicitNamespace = hasExplicitNamespace;
this.name = name;
this.namespace = namespace;

this.children = children && cloneAndUpdateNodes(children, this);

for (const key of Object.keys(opts)) {
const value = opts[key];
if (key in NODES_KEYS) {
this._setNodes(key, value);
} else {
Expand Down

0 comments on commit 1024b24

Please sign in to comment.