File tree Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -79,14 +79,10 @@ export default function finalCleanup(path: NodePath<t.Function>): void {
79
79
)
80
80
} else argument . remove ( )
81
81
} else if ( value . isCallExpression ( ) && isPromiseRejectCall ( value ) ) {
82
- path . replaceWith (
83
- t . throwStatement (
84
- t . newExpression (
85
- t . identifier ( 'Error' ) ,
86
- value . node . arguments . slice ( 0 , 1 )
87
- )
88
- )
89
- )
82
+ const argument = value . node . arguments [ 0 ]
83
+ if ( t . isExpression ( argument ) ) {
84
+ path . replaceWith ( t . throwStatement ( argument ) )
85
+ }
90
86
} else if ( argument . isAwaitExpression ( ) && ! isInTryBlock ( path ) ) {
91
87
argument . replaceWith ( argument . node . argument )
92
88
}
Original file line number Diff line number Diff line change
1
+ export const input = `
2
+ function foo() {
3
+ return Promise.reject(new Error('test'))
4
+ }
5
+ `
6
+
7
+ export const options = { }
8
+
9
+ export const expected = `
10
+ async function foo() {
11
+ throw new Error('test')
12
+ }
13
+ `
You can’t perform that action at this time.
0 commit comments