-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed functions that are imported then re-exported causing a crash #28
Conversation
@@ -7,6 +7,8 @@ This changelog documents the changes between release versions. | |||
## [Unreleased] | |||
Changes to be included in the next upcoming release | |||
|
|||
- Fixed functions that are imported then re-exported causing a crash [#28](https://github.com/hasura/ndc-nodejs-lambda/pull/28) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
const exportTargetDeclaration = | ||
exportTarget.valueDeclaration // 'export { name } from "./imported"' | ||
?? typeChecker.getAliasedSymbol(exportTarget).valueDeclaration // 'import { name } from "./imported"; export { name }' | ||
?? throwError("export target symbol does not have a value declaration"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
import { fileAChildFunction as renamedFileAChildFunction } from "./file-a" | ||
import { fileBChildFunction1, fileBChildFunction2 } from "./file-b" | ||
|
||
export { | ||
renamedFileAChildFunction, | ||
fileBChildFunction1, | ||
fileBChildFunction2 as renamedFileBChildFunction2 | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -206,4 +206,65 @@ describe("re-exported functions", function() { | |||
} | |||
}) | |||
}); | |||
|
|||
it("supports re-exports of functions from other files that are first imported then exported", function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
This PR fixes a bug where if one was to re-export functions from another file like so:
you would cause the type inference to crash. This PR fixes the type inference so it correctly handles this corner case by following the import symbol's alias to its source then getting its declaration.