Repository: TypeScript
Issue: Crash when transformer mutates decorators on classes with initialized static fields
Labels: Bug,Rescheduled

# Bug Report

### 🔎 Search Terms

- Debug Failure Invalid Cast isCallExpression
- Debug Failure while transforming decorators on class

### 🕗 Version & Regression Information

- This is a crash in (at least) Typescript 4.6 and 4.7

### ⏯ Playground Link

I'm not sure how to set up a Bug Workbench for transformers, but I do have a very terse isolated reproduction at https://github.com/typescript-rtti/ts-transform-bug

### 💻 Code

<!-- Please post the relevant code sample here as well-->

Code being transformed:

```ts
class A {
    static stuff = 'things';
}
```

Transformer:

```ts
import * as ts from 'typescript';

const transformer: (program: ts.Program) => ts.TransformerFactory<ts.SourceFile> = (program: ts.Program) => {
    const transform: ts.TransformerFactory<ts.SourceFile> = (context: ts.TransformationContext) => {
        return sourceFile => {
            console.log(`Transforming source file '${sourceFile.fileName}'...`);
            function visitor(node: ts.Node) {
                if (ts.isClassDeclaration(node)) {
                    return ts.factory.updateClassDeclaration(
                        node,
                        ts.factory.createNodeArray(node.decorators),
                        node.modifiers,
                        node.name,
                        node.typeParameters,
                        node.heritageClauses,
                        node.members
                    )
                }
                return ts.visitEachChild(node, visitor, context);
            }

            return ts.visitNode(sourceFile, visitor);
        }
    };

    return transform;
};

export default transformer;
```

### 🙁 Actual behavior

```
Error: Debug Failure. Invalid cast. The supplied value [object Object] did not pass the test 'isCallExpression'.
    at Object.cast (D:\Dev\typescript-rtti\ts-transform-bug\node_modules\typescript\lib\typescript.js:1847:25)
    at visitTypeScriptClassWrapper (D:\Dev\typescript-rtti\ts-transform-bug\node_modules\typescript\lib\typescript.js:101166:27)
    at visitCallExpression (D:\Dev\typescript-rtti\ts-transform-bug\node_modules\typescript\lib\typescript.js:101086:24)
    at visitorWorker (D:\Dev\typescript-rtti\ts-transform-bug\node_modules\typescript\lib\typescript.js:98718:28)
    at visitor (D:\Dev\typescript-rtti\ts-transform-bug\node_modules\typescript\lib\typescript.js:98639:44)
    at visitNode (D:\Dev\typescript-rtti\ts-transform-bug\node_modules\typescript\lib\typescript.js:89314:23)
    at Object.visitEachChild (D:\Dev\typescript-rtti\ts-transform-bug\node_modules\typescript\lib\typescript.js:89826:236)
    at visitVariableDeclaration (D:\Dev\typescript-rtti\ts-transform-bug\node_modules\typescript\lib\typescript.js:100136:30)
    at visitorWorker (D:\Dev\typescript-rtti\ts-transform-bug\node_modules\typescript\lib\typescript.js:98680:28)
    at visitor (D:\Dev\typescript-rtti\ts-transform-bug\node_modules\typescript\lib\typescript.js:98639:44)
```

### 🙂 Expected behavior

The transformer should be able to transform the class node without causing the above debug failure crash.