File tree Expand file tree Collapse file tree 2 files changed +14
-15
lines changed Expand file tree Collapse file tree 2 files changed +14
-15
lines changed Original file line number Diff line number Diff line change 14
14
* limitations under the License.
15
15
*/
16
16
17
- import { Transform } from '../types' ;
17
+ import { Transform , Range } from '../types' ;
18
18
import { TransformSourceDescription } from 'rollup' ;
19
19
import MagicString from 'magic-string' ;
20
20
import { ObjectExpression } from 'estree' ;
@@ -40,21 +40,18 @@ export default class LiteralComputedKeys extends Transform {
40
40
41
41
walk . simple ( program , {
42
42
ObjectExpression ( node : ObjectExpression ) {
43
- const properties = node . properties ;
44
- properties . forEach ( property => {
45
- if (
46
- property . computed &&
47
- property . key . type === 'Literal' &&
48
- property . range &&
49
- property . value . range
50
- ) {
43
+ for ( const property of node . properties ) {
44
+ const [ propertyStart ] : Range = property . range as Range ;
45
+ const [ valueStart ] : Range = property . value . range as Range ;
46
+
47
+ if ( property . computed && property . key . type === 'Literal' ) {
51
48
source . overwrite (
52
- property . range [ 0 ] ,
53
- property . value . range [ 0 ] ,
49
+ propertyStart ,
50
+ valueStart ,
54
51
`${ property . key . value } ${ property . value . type !== 'FunctionExpression' ? ':' : '' } ` ,
55
52
) ;
56
53
}
57
- } ) ;
54
+ }
58
55
} ,
59
56
} ) ;
60
57
Original file line number Diff line number Diff line change 14
14
* limitations under the License.
15
15
*/
16
16
17
- import { Transform } from '../types' ;
17
+ import { Transform , Range } from '../types' ;
18
18
import { isESMFormat } from '../options' ;
19
19
import { TransformSourceDescription } from 'rollup' ;
20
20
import MagicString from 'magic-string' ;
@@ -41,8 +41,10 @@ export default class StrictTransform extends Transform {
41
41
walk . simple ( program , {
42
42
ExpressionStatement ( node : ExpressionStatement ) {
43
43
const { type, value } = node . expression as SimpleLiteral ;
44
- if ( type === 'Literal' && value === 'use strict' && node . range ) {
45
- source . remove ( ...node . range ) ;
44
+ const range : Range = node . range as Range ;
45
+
46
+ if ( type === 'Literal' && value === 'use strict' ) {
47
+ source . remove ( ...range ) ;
46
48
}
47
49
} ,
48
50
} ) ;
You can’t perform that action at this time.
0 commit comments