Repository: TypeScript
Issue: Passing Class as a parameter of creation function for static field in decorated class will result into passing undefined instead of a class
Labels: Bug

# Bug Report

### :mag_right: Search Terms

Passing class into static field creation in decorated class causes passing `undefined` to creating function

### :clock8: Version & Regression Information

- This changed between versions `4.3.4` and `4.4.3`

### :play_or_pause_button: Playground Link

[Not working (4.4.3)](https://www.typescriptlang.org/play?useDefineForClassFields=true&removeComments=true&importHelpers=true&target=99&jsx=0&module=1&inlineSources=true&inlineSourceMap=true&allowSyntheticDefaultImports=true&ts=4.4.3#code/C4TwDgpgBAogHgQwLZgDYQCrmgXigbwCgooBjVBAZ0oDlkIAuKS4AJwEsA7AcwG5CAvoUIAzAK6dSwdgHtOUAMrsU6AIKdOwGcATS5ACgCUBYlFYRgY1vPGS98-aTktWYqTNZMAYhKmzOxkQkAvxCor72ZOa6EF6sMkgAwhTUADwYAHyOFABeOUycEADuUPoAdBUIrNyUTAicIMY4GVAYhkzwyGiY2CYkJE6clDLoZagy3PoABslUtVAAJPjkCHkCU4b8-WTOIxBjE9Oz1HRIjIvLuTllnPTrm8KmJOaW1n3bZCm09EwreTf0J5QIRhFbUWCIFQQY6UEhBKBgDgANxizB00lIigwqgwAElEgB9ABqqgASh1Id0sJAoHhSNFgLF4kkvvpOlCYQ9TGAxAAjVDsTGUAAWMiKAFkQNSIEZ3gNdqNxpMpgpsXjCSTyRd2d0YWVVTj8cSyWUwd8zvdTCDhAABJRQ9SabS6fxGQhmqAAEQgTlYMQAJjr0DD3oj2CjGWiXZiDerjVqgz0aXSGUyEjD9N7fQHE5z+Ny+QKhaKJVLsLL4fKhnsDsrY0bNUwllmPDnKcGvvq1Q2TWbThBLcFBMJCiVc6zDGURWLJdKjPxR16fa3GYH29CJ1OS7Py5sgA)

[Not working (4.3.5)](https://www.typescriptlang.org/play?useDefineForClassFields=true&removeComments=true&importHelpers=true&target=99&jsx=0&module=1&inlineSources=true&inlineSourceMap=true&allowSyntheticDefaultImports=true&ts=4.3.5#code/C4TwDgpgBAogHgQwLZgDYQCrmgXigbwCgooBjVBAZ0oDlkIAuKS4AJwEsA7AcwG5CAvoUIAzAK6dSwdgHtOUAMrsU6AIKdOwGcATS5ACgCUBYlFYRgY1vPGS98-aTktWYqTNZMAYhKmzOxkQkAvxCor72ZOa6EF6sMkgAwhTUADwYAHyOFABeOUycEADuUPoAdBUIrNyUTAicIMY4GVAYhkzwyGiY2CYkJE6clDLoZagy3PoABslUtVAAJPjkCHkCU4b8-WTOIxBjE9Oz1HRIjIvLuTllnPTrm8KmJOaW1n3bZCm09EwreTf0J5QIRhFbUWCIFQQY6UEhBKBgDgANxizB00lIigwqgwAElEgB9ABqqgASh1Id0sJAoHhSNFgLF4kkvvpOlCYQ9TGAxAAjVDsTGUAAWMiKAFkQNSIEZ3gNdqNxpMpgpsXjCSTyRd2d0YWVVTj8cSyWUwd8zvdTCDhAABJRQ9SabS6fxGQhmqAAEQgTlYMQAJjr0DD3oj2CjGWiXZiDerjVqgz0aXSGUyEjD9N7fQHE5z+Ny+QKhaKJVLsLL4fKhnsDsrY0bNUwllmPDnKcGvvq1Q2TWbThBLcFBMJCiVc6zDGURWLJdKjPxR16fa3GYH29CJ1OS7Py5sgA)

[Working with keyword `this` (4.3.5)](https://www.typescriptlang.org/play?useDefineForClassFields=true&removeComments=true&importHelpers=true&target=99&jsx=0&module=1&inlineSources=true&inlineSourceMap=true&allowSyntheticDefaultImports=true&ts=4.3.5#code/C4TwDgpgBAogHgQwLZgDYQCrmgXigbwCgooBjVBAZ0oDlkIAuKS4AJwEsA7AcwG5CAvoUIAzAK6dSwdgHtOUAMrsU6AIKdOwGcATS5ACgCUBYlFYRgY1vPGS98-aTktWYqTNZMAYhKmzOxkQkAvxCor72ZOa6EF6sMkgAwhTUADwYAHyOFABeOUycEADuUPoAdBUIrNyUTAicIMY4GVAYhkzwyGiY2CYkJE6clDLoZagy3PoABslUtVAAJPjkCHkCU4b8-WTOIxBjE9Oz1HRIjIvLuTllnPTrm8KmJOaW1n3bZCm09EwreTf0J5QIRhFbUWCIFQQY6UEhBKBgDgANxizB00lIigwqgwAElEgB9ABqqgASh1Id0sJAoHhSNFgLF4kkvvpgAALdiUB6mMBiABGqHYmMo7JkRQAsiBqRAjO8BrtRuNJlMFNi8YSSeSLp0oTCymqcfjiWSymDvmd7qYQcIAAJKKHqTTaXT+IyEc1QAAiECcrBiABNdd0Ye9EewUYy0a7MYaNSbtcH0DLaVEIDE4gkYWzOdz+LyBUKRWLJdLsHL4QqhnsDiq48atUwlj6-YGk9Cvgb1Q3TebThArcFBMJCiV29nDGVReKpTKjPxR97fR425T0BOpyXZ+XNkA)

### :computer: Code

Target: `ESNext`
Module: `CommonJS`

<!-- Please post the relevant code sample here as well-->
```ts
type ExampleType = {
  className: string;
}

function SimpleAnntotation() {
  return function (constructor: Function) {
  };
}

function createFromClass<T>(clazz: new (...args: any) => T): ExampleType {
    console.log(`Class: ${clazz}`);
    console.log(`ClassName: ${clazz.name}`);


    return {
      className: clazz.name
    }
}

@SimpleAnntotation()
class DecoratedExampleClass {
  private static STATIC_VAR: ExampleType = createFromClass(DecoratedExampleClass);

  public showMyType() {
    console.log(`STATIC_VAR: ${DecoratedExampleClass.STATIC_VAR.className}`)
  }
}

new DecoratedExampleClass().showMyType();
```
### :slightly_frowning_face: Actual behavior

Passing Class as a parameter of creation function for static field in decorated class will result into passing `undefined` instead of a class

### :slightly_smiling_face: Expected behavior

Passing Class as a parameter of creation function for static field in decorated class should pass class as it happens for the non-decorated class

###  :scroll: Explanation
In `4.3.3` it was not possible to pass Class as parameter to function that initializes static field as argument to such function always ends up as `undefined`. Instead, after using keyword `this` and TS config option `useDefineForClassFields` to true this parameter was properly resolved and class was passed as an argument.

Now in `4.4.3` you cannot pass this in static field initialization due to `TS2816: Cannot use 'this' in a static property initializer of a decorated class.` thus it's not possible to pass class as an argument during static class initalization.

Have in mind that (at least with `4.4.3` version) it is possible to do that when class is not decorated - the argument is properly resolved.