fix: export w/ curly brace on next line, extra curly brace before def #1075
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
Fix this issue: withastro/astro#13790, where a curly brace which is not the start of a function body is incorrectly classified as such.
This is just a patch for the case reported in this issue and a few other ones, such as:
export function getStaticPaths(input: { paginate: any })
export const getStaticPaths: () => { params: any }[]
There may be an additional case that I missed, please let me know if you can think of one!
Note
Though I did not do this in this PR to minimize the surface area of the changes, in my opinion it would be worthwhile to pull in a full-fledged TS parser and operate on the AST for this export hoisting use case. Perhaps when the new TS Go compiler from Microsoft is stable the parser can be taken from there 🤷
Testing
Tests added to appropriate files
Docs
Bug fix, no changes to public API