Skip to content

Incorrect decorator transformation #11744

@PupilTong

Description

@PupilTong

Describe the bug

The static property of ES6 class which is inherited by decorator function is incorrectly transformed.

Input code

function Component(target) {
  return class subTarget extends target {};
}

@Component
class ScrollView {
  static scrollInterval = 100;
  autoScroll() {
    console.log(ScrollView.scrollInterval)
  }
}

new ScrollView().autoScroll();

Config

Link to the code that reproduces this issue

https://play.swc.rs/?version=1.15.21&code=H4sIAAAAAAAAA1WNvQrCMBRG9zzFN6ZLqXMRBCdnxT3GaynEeyW5qULpu1sbsLp%2BP%2BfcMnvthbGX%2B0OYWK262JFWGA0QSXNk%2BOBSQsqX09KBXkp8TShTjFNrJmN2X4Yph6OPEsK5p%2BcCS%2Bq090hLemClOLiALTZN0861yyrlYYsc8MJJAtVBOrvC6n9CNU%2Bnj59nz7qyVf1LbN%2FcAyXY6gAAAA%3D%3D&config=H4sIAAAAAAAAA12Puw6DMAxFd74CZW4lRLfOXbt2j4JBqUIc2UZqhPh3AgRKu9n3cWSPRVmqNxt1L8c0piVoYqBjTwpHL%2FqTFCUxABuyQdRldxswSFqQOCWEBliNafOVkPbcIvVn4FF5AbFFv6Drqq6v1e3LddBpEx97NGVa7fiPrqkDWerACyC3lUNk2BtZ6623bTyfYbAPBMy%2F6CLjleUnNoOD%2FNaqHZCtMBUzcaRJAkABAAA%3D

SWC Info output

No response

Expected behavior

the 100 is supposed to be printed

Actual behavior

the undefined is printed

Version

1.15.21

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions