Skip to content
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

feat: add exportable internal functions #529

Merged
merged 4 commits into from
May 6, 2021

Conversation

willemneal
Copy link
Contributor

@willemneal willemneal commented May 6, 2021

fixes #491

Submodule functions decorated with @nearBindgen are wrapped in the same manner as those exported from the entry file. This also helps to signal that this function will be a module export to the reader.

For example,

index.ts

export { foo} from "./foo"

foo.ts

// @ts-ignore
@nearBindgen
export function foo(): string {
  return "hello";
}

Unfortunately Typescript doesn't allow decorators on

@willemneal willemneal requested a review from mehtaphysical May 6, 2021 17:38
Copy link
Contributor

@mehtaphysical mehtaphysical left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Cool feature.

simulator/__tests__/cross.spec.ts Outdated Show resolved Hide resolved
simulator/__tests__/cross.spec.ts Outdated Show resolved Hide resolved
if (
!isExport ||
alreadyWrapped ||
noInputOrOutput ||
Copy link
Contributor

@mehtaphysical mehtaphysical May 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! just realizing now that:

export { myFunc } from './path.ts'

was always possible as long as myFunc had no inputs or outputs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep!

@willemneal willemneal merged commit 080501b into master May 6, 2021
@mehtaphysical mehtaphysical deleted the feat/wrap_exported_functions_from_non-entry branch June 9, 2021 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exporting functions from submodules
2 participants