@@ -360,13 +360,19 @@ export function hasDefaultExport(ast: AST): boolean {
360
360
*
361
361
* - `"...restElemet1"` --> `"restElement1"`
362
362
* - `"...restElemet2"` --> `"restElement2"`
363
+ *
364
+ * DISCLAIMER: This function only correcly extracts the name of `RestElements` in the context of export statements.
365
+ * Using this for `RestElements` outside of exports would require us to handle more edgecases. Hence the "Export" in
366
+ * this function's name.
363
367
*/
364
368
function getExportIdentifiersFromRestElement ( restElement : jscsTypes . RestElement ) : string [ ] {
365
369
// This function returns an array instead of `string | undefined` for convenience since we exclusively use the return
366
370
// value with `array.push()` in other functions in this file.
367
371
return Identifier . check ( restElement . argument ) ? [ restElement . argument . name ] : [ ] ;
368
372
}
369
373
374
+ const asdf = { ...( { a : 1 } || { b : 2 } ) } ;
375
+
370
376
/**
371
377
* Extracts all identifier names (`'constName'`) from an destructuringassignment'sArrayPattern (the `[constName]` in`const [constName] = [1]`).
372
378
*
@@ -383,6 +389,10 @@ function getExportIdentifiersFromRestElement(restElement: jscsTypes.RestElement)
383
389
* `[{ foo: name1 }, [{ bar: [name2]}, name3]]`
384
390
*
385
391
* Applying this function to this `ArrayPattern` will return the following: `["name1", "name2", "name3"]`
392
+ *
393
+ * DISCLAIMER: This function only correcly extracts identifiers of `ArrayPatterns` in the context of export statements.
394
+ * Using this for `ArrayPattern` outside of exports would require us to handle more edgecases. Hence the "Export" in
395
+ * this function's name.
386
396
*/
387
397
function getExportIdentifiersFromArrayPattern ( arrayPattern : jscsTypes . ArrayPattern ) : string [ ] {
388
398
const identifiers : string [ ] = [ ] ;
@@ -412,6 +422,10 @@ function getExportIdentifiersFromArrayPattern(arrayPattern: jscsTypes.ArrayPatte
412
422
* Example:
413
423
* export const { foo: [name1], bar: { baz: [{ quux: name2 }], ...name3 }} = { foo: [1], bar: { baz: [{ quux: 3 }]} };
414
424
* --> ["name1", "name2", "name3"]
425
+ *
426
+ * DISCLAIMER: This function only correcly extracts identifiers of `ObjectPatterns` in the context of export statements.
427
+ * Using this for `ObjectPatterns` outside of exports would require us to handle more edgecases. Hence the "Export" in
428
+ * this function's name.
415
429
*/
416
430
function getExportIdentifiersFromObjectPattern ( objectPatternNode : jscsTypes . ObjectPattern ) : string [ ] {
417
431
const identifiers : string [ ] = [ ] ;
0 commit comments