use quick method instead of create for more concise type creation
MODIFY
packages/@romejs/js-compiler/transforms/lint/sparseArray.ts
packages/@romejs/js-compiler/transforms/lint/sparseArray.ts
import {Path} from '@romejs/js-compiler';
import {AnyNode} from '@romejs/js-ast';
-import {
- referenceIdentifier,
- arrayExpression,
- ArrayExpression,
-} from '@romejs/js-ast';
+import {referenceIdentifier, arrayExpression} from '@romejs/js-ast';
export default {
name: 'sparseArray',
@@ -23,15 +19,13 @@ export default {
category: 'lint/sparseArray',
message: 'Your array contains an empty slot',
});
- const fixedArray: ArrayExpression = {
- type: 'ArrayExpression',
- elements: node.elements.map(elem =>
+ return arrayExpression.quick(
+ node.elements.map(elem =>
elem === undefined
? referenceIdentifier.create({name: 'undefined'})
: elem,
),
- };
- return arrayExpression.create(fixedArray);
+ );
}
return node;

use quick method instead of create for more concise type creation