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: botbuilder stdlib #3066

Merged
merged 15 commits into from
Dec 4, 2020
Merged

feat: botbuilder stdlib #3066

merged 15 commits into from
Dec 4, 2020

Conversation

joshgummersall
Copy link
Contributor

This PR introduces a new package, botbuilder-stdlib, that exports some helpful shared utilities. The type assertion code will provide a robust way to construct type assertions that perform runtime type validation and compile-time type hinting. The result will be more type-safe code and a developer experience that better leverages IntelliSense.

A note for code reviewers: the botframework-schema diff is quite large due to prettier code formatting changes. I performed the code formatting step as a separate commit before adding the new type assertions. Hopefully, that makes this a bit easier to review.

I'm open to feedback on the developer ergonomics for asserting types. Unfortunately, the compiler requires that type assertions functions do not reference type parameters without an explicit type declaration (i.e. assert.arrayOf(assert.string) is not possible without const arrayOfStrings: Assertion<Array<string>> = assert.arrayOf(assert.string)). This means that chaining and other helper functions are basically impossible to write. If you notice some verbose type declarations, that's why.

@joshgummersall joshgummersall force-pushed the jpg/botbuilder-stdlib branch 2 times, most recently from cf27fab to 97d784a Compare November 16, 2020 22:38
Copy link
Member

@stevengum stevengum 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! Two small things in the package.json for botbuilder-stdlib.

@joshgummersall joshgummersall force-pushed the jpg/botbuilder-stdlib branch 2 times, most recently from 24ce01f to 10fd5ee Compare November 17, 2020 17:37
@coveralls
Copy link

coveralls commented Nov 17, 2020

Pull Request Test Coverage Report for Build 401371168

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 153 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-0.3%) to 84.393%

Files with Coverage Reduction New Missed Lines %
libraries/botbuilder-core/src/storage.ts 1 90.0%
libraries/botbuilder-azure-blobs/src/blobsStorage.ts 16 28.57%
libraries/botbuilder-azure-blobs/src/blobsTranscriptStore.ts 37 9.95%
libraries/botframework-schema/src/index.ts 99 64.89%
Totals Coverage Status
Change from base Build 401242264: -0.3%
Covered Lines: 17556
Relevant Lines: 19877

💛 - Coveralls

@joshgummersall joshgummersall force-pushed the jpg/botbuilder-stdlib branch 2 times, most recently from de4bceb to 0ea72e2 Compare November 18, 2020 17:53
Copy link
Member

@stevengum stevengum left a comment

Choose a reason for hiding this comment

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

Temporarily blocking PR while we get other feedback

@joshgummersall joshgummersall force-pushed the jpg/botbuilder-stdlib branch 2 times, most recently from 39aa573 to 3b3f451 Compare November 30, 2020 17:40
Copy link
Member

@stevengum stevengum left a comment

Choose a reason for hiding this comment

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

At the moment I think the doc strings need to be updated with xrefs otherwise the expectation is that the developer is already familiar with the contents of botbuilder-stdlib. I worry a little that a dev might wander in here, use the provided functions and introduce a bug due to expectations on either Node or TypeScript behavior that aren't the exact same as in this library.

This isn't a requirement for this PR as this package is essentially internal, but something to be considered for the future.

What do you think?

@joshgummersall
Copy link
Contributor Author

That's totally fair - my plan is twofold. First, carefully review the use of the type assertions/tests (especially unsafe). Second, improve the dev experience based on feedback from the team. I'm going to rewrite the assertions to have better JSDoc comments, for now, I think that will provide a good starting place.

@joshgummersall joshgummersall force-pushed the jpg/botbuilder-stdlib branch 3 times, most recently from 1fd6763 to 91b64dd Compare December 2, 2020 22:43
Copy link
Member

@stevengum stevengum left a comment

Choose a reason for hiding this comment

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

:shipit:

One small suggestion. but otherwise LGTM

@joshgummersall joshgummersall merged commit 979666e into main Dec 4, 2020
@joshgummersall joshgummersall deleted the jpg/botbuilder-stdlib branch December 4, 2020 22:42
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.

3 participants