File tree Expand file tree Collapse file tree 15 files changed +156
-0
lines changed
test/fixtures/convert/decorator
decorator-on-class-with-argument Expand file tree Collapse file tree 15 files changed +156
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ test/fixtures/convert/formatting
2
2
test /fixtures /convert /imports /named_import_specifier_kind /
3
3
test /fixtures /convert /function-types /predicate03
4
4
test /fixtures /convert /imports /dynamic_import
5
+ test /fixtures /convert /decorator /
5
6
playground /static
6
7
babel-traverse
7
8
babel-types
Original file line number Diff line number Diff line change @@ -4,6 +4,10 @@ const presets = [
4
4
5
5
const commonPlugins = [
6
6
"@babel/plugin-proposal-class-properties" ,
7
+ [
8
+ "@babel/plugin-proposal-decorators" ,
9
+ { legacy : true } ,
10
+ ] ,
7
11
[ "module-resolver" , {
8
12
"alias" : {
9
13
"^@babel/(.+)" : "./babel/packages/babel-\\1/src/index"
Original file line number Diff line number Diff line change 26
26
"devDependencies" : {
27
27
"@babel/core" : " ^7.13.10" ,
28
28
"@babel/plugin-proposal-class-properties" : " ^7.13.0" ,
29
+ "@babel/plugin-proposal-decorators" : " ^7.13.5" ,
29
30
"@babel/plugin-transform-flow-strip-types" : " ^7.13.0" ,
30
31
"@babel/plugin-transform-typescript" : " ^7.13.0" ,
31
32
"@babel/preset-env" : " ^7.13.10" ,
49
50
"webpack-cli" : " ^4.5.0"
50
51
},
51
52
"scripts" : {
53
+ "prepare" : " git submodule update --init --recursive && cd babel && yarn install && cd .." ,
52
54
"prepublishOnly" : " webpack build" ,
53
55
"build" : " webpack build" ,
54
56
"type-check" : " tsc --project tsconfig.json" ,
Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ export const parseOptions: ParserOptions = {
22
22
"nullishCoalescingOperator" ,
23
23
"classPrivateProperties" ,
24
24
"classPrivateMethods" ,
25
+ // decorators
26
+ "decorators-legacy" ,
25
27
] ,
26
28
} ;
27
29
Original file line number Diff line number Diff line change
1
+ function inject ( options : {
2
+ api_version : string ;
3
+ } ) {
4
+ return target => target ;
5
+ }
6
+
7
+ @inject ( {
8
+ api_version : "0.3.4"
9
+ } )
10
+ class MyComponent extends React . Component < Props > {
11
+ render ( ) {
12
+ return document . createElement ( "div" ) ;
13
+ }
14
+
15
+ }
Original file line number Diff line number Diff line change
1
+ function inject ( options : {
2
+ api_version : string ;
3
+ } ) {
4
+ return target => target ;
5
+ }
6
+
7
+ @inject ( {
8
+ api_version : "0.3.4"
9
+ } )
10
+ class MyComponent extends React . Component < Props > {
11
+ render ( ) {
12
+ return document . createElement ( "div" ) ;
13
+ }
14
+
15
+ }
Original file line number Diff line number Diff line change
1
+ import { autoBindMethodsForReact } from "class-autobind-decorator" ;
2
+
3
+ @autoBindMethodsForReact ( AUTOBIND_CFG )
4
+ class PasswordEditor extends React . PureComponent < Props , State > {
5
+ constructor ( props : Props ) {
6
+ super ( props ) ;
7
+ this . state = {
8
+ showPassword : false
9
+ } ;
10
+ }
11
+
12
+ }
Original file line number Diff line number Diff line change
1
+ import { autoBindMethodsForReact } from "class-autobind-decorator" ;
2
+
3
+ @autoBindMethodsForReact ( AUTOBIND_CFG )
4
+ class PasswordEditor extends React . PureComponent < Props , State > {
5
+ constructor ( props : Props ) {
6
+ super ( props ) ;
7
+ this . state = {
8
+ showPassword : false
9
+ } ;
10
+ }
11
+
12
+ }
Original file line number Diff line number Diff line change
1
+ import { observer } from "mobx" ;
2
+
3
+ @observer
4
+ class Store {
5
+ constructor ( ) { }
6
+
7
+ }
8
+
9
+ export default Store ;
Original file line number Diff line number Diff line change
1
+ import { observer } from "mobx" ;
2
+
3
+ @observer
4
+ class Store {
5
+ constructor ( ) { }
6
+
7
+ }
8
+
9
+ export default Store ;
You can’t perform that action at this time.
0 commit comments