Skip to content

Commit

Permalink
style: remove todo comment from updateClassDeclaration
Browse files Browse the repository at this point in the history
A transformer should not mutate existing nodes, ever. If you intend to modify some part of the node, the ts.update* methods are correct. Or you can replace a node entirely via ts.create* operations, but there are cases where introducing entirely synthetic nodes will break TS output.

Hence using the updateClassDeclaration in this case is the correct approach.

This has also been raised in the slack #ts-core channel as TypeScript have been looking to get to the bottom of this microsoft/TypeScript#29365 (comment), which seemed to have been caused by mutating the node.
  • Loading branch information
alan-agius4 authored and alexeagle committed Apr 4, 2019
1 parent 2888cc7 commit f490c2a
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/transformers/replace_resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ export function replaceResources(
(node: ts.Decorator) => visitDecorator(node, typeChecker, directTemplateLoading),
);

// todo: we need to investigate and confirm that using
// `updateClassDeclaration` has no regressions
return ts.updateClassDeclaration(
node,
decorators,
Expand Down

0 comments on commit f490c2a

Please sign in to comment.