Skip to content

Commit

Permalink
fix: use correct precedence for right side of arrow function
Browse files Browse the repository at this point in the history
  • Loading branch information
simonseyock committed Jan 17, 2022
1 parent e4aa3be commit 6b0a410
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parslets/ArrowFunctionParslet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const arrowFunctionParslet = composeParslet({
parameters: getParameters(left).map(assertPlainKeyValueOrNameResult),
arrow: true,
parenthesis: true,
returnType: parser.parseType(Precedence.ALL)
returnType: parser.parseType(Precedence.OBJECT)
}
}
})
49 changes: 49 additions & 0 deletions test/fixtures/typescript/arrowFunction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,55 @@ describe('typescript arrow function tests', () => {
}
})
})

describe('arrow as first object property', () => {
testFixture({
input: '{x: () => void, y: string}',
modes: ['typescript'],
expected: {
type: 'JsdocTypeObject',
elements: [
{
type: 'JsdocTypeKeyValue',
key: 'x',
right: {
type: 'JsdocTypeFunction',
parameters: [],
returnType: {
type: 'JsdocTypeName',
value: 'void'
},
arrow: true,
parenthesis: true
},
optional: false,
readonly: false,
meta: {
quote: undefined,
hasLeftSideExpression: false
}
},
{
type: 'JsdocTypeKeyValue',
key: 'y',
right: {
type: 'JsdocTypeName',
value: 'string'
},
optional: false,
readonly: false,
meta: {
quote: undefined,
hasLeftSideExpression: false
}
}
],
meta: {
separator: 'comma'
}
}
})
})
})

// TODO:
Expand Down

0 comments on commit 6b0a410

Please sign in to comment.