File tree Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ export function walkDoc(
10
10
startDoc : Doc ,
11
11
/** Return something falsy to prevent walking of child docs */
12
12
debug : boolean ,
13
+ /** If this returns something falsy, none of the current node's children will be walked. */
13
14
callback : (
14
15
currentDoc : Doc ,
15
16
parents : Parents [ ] ,
Original file line number Diff line number Diff line change @@ -50,7 +50,15 @@ function insertLinesIntoArray(
50
50
console . info ( stringify ( parentDoc ) ) ;
51
51
}
52
52
if ( childIndex !== 0 ) {
53
- throw new Error ( `${ found } not at index 0 in its parent` ) ;
53
+ /**
54
+ * This happens in some situations which we don't want to format in this plugin,
55
+ * like in type accessors:
56
+ *
57
+ * ```typescript
58
+ * type mockType = exampleObject['property'];
59
+ * ```
60
+ */
61
+ return true ;
54
62
}
55
63
56
64
const maybeBreak = parentDoc [ childIndex + 2 ] ;
Original file line number Diff line number Diff line change @@ -34,6 +34,17 @@ export const typescriptTests: MultilineArrayTest[] = [
34
34
multilineArraysWrapThreshold : 0 ,
35
35
} ,
36
36
} ,
37
+ {
38
+ it : 'works with type accessors' ,
39
+ code : `
40
+ export function doThing(
41
+ [
42
+ data,
43
+ ]: Parameters<stuff['param']>,
44
+ thing: string,
45
+ ) {}
46
+ ` ,
47
+ } ,
37
48
{
38
49
it : 'works even if filepath is undefined GitHub Issue #18 (thank you farmerpaul)' ,
39
50
code : `
You can’t perform that action at this time.
0 commit comments