Skip to content

Commit

Permalink
Use internal assign from @glimmer/utils
Browse files Browse the repository at this point in the history
The project already has handling for using `Object.assign` if available
and a polyfill if not; use it!
  • Loading branch information
chriskrycho committed Oct 22, 2021
1 parent b36ef11 commit e57c5e0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/@glimmer/syntax/lib/v2-a/objects/node.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { assign } from '@glimmer/util';

import { SourceSpan } from '../../source/span';

export interface BaseNodeFields {
Expand Down Expand Up @@ -54,13 +56,13 @@ export function node<T extends string>(
return {
fields<Fields extends object>(): TypedNodeConstructor<T, BaseNodeFields & Fields> {
return class {
// SAFETY: initialized via Object.assign in the constructor.
// SAFETY: initialized via `assign` in the constructor.
declare readonly loc: SourceSpan;
readonly type: T;

constructor(fields: BaseNodeFields & Fields) {
this.type = type;
Object.assign(this, fields);
assign(this, fields);
}
} as TypedNodeConstructor<T, BaseNodeFields & Fields>;
},
Expand All @@ -69,11 +71,11 @@ export function node<T extends string>(
return {
fields<Fields>(): NodeConstructor<Fields & BaseNodeFields> {
return class {
// SAFETY: initialized via Object.assign in the constructor.
// SAFETY: initialized via `assign` in the constructor.
declare readonly loc: SourceSpan;

constructor(fields: BaseNodeFields & Fields) {
Object.assign(this, fields);
assign(this, fields);
}
} as NodeConstructor<BaseNodeFields & Fields>;
},
Expand Down

0 comments on commit e57c5e0

Please sign in to comment.