-
Notifications
You must be signed in to change notification settings - Fork 132
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
Use TS Morph to generate type predicates #1278
Conversation
We should probably run tsc on the generated ts code after generation is complete to make sure it's all good. Does that currently happen? |
we should probably also generate type predicates for the context objects as well. |
We currently just run the type generation and then the linter vai teh Line 26 in aa276dd
In the fdc3-for-web branch this is now set to happen on a pre-commit hook. I haven't had time to take a proper look at this PR yet, but I wanted to get you an answer on the above. |
Yes we should! This is the PR that touched those last and introduced some util functions based on them: https://github.com/finos/FDC3/pull/1139/files If you have a minute do please take a look and compare notes. |
bd27747
to
e2a8a55
Compare
@Roaders do you still want to do this? I had review this (finally) on my todo list for this week and next. |
yes I do. I actually meant to extend it a bit. A union type for all the request messages would be very useful for Discriminated unions and Exhaustiveness checking when handling request messages in the root agent for example. |
oh dammit. I've accidentally closed this. Sorry, I'll raise a new PR. |
New PR: #1387 |
adresses #1268
This is a very rough cut and really just proves that what I was planning does work.
We could generate the predicates in a different file if we wanted to. We could also generate union types of the request and response messages if we wanted to.
I had some issues getting ts-node working initially hence the extra tsconfig file. We can move the
generate-type-predicates
file into the root of the project if desired.THIS SOFTWARE IS CONTRIBUTED SUBJECT TO THE TERMS OF THE FINOS CORPORATE CONTRIBUTOR LICENSE AGREEMENT.
THIS SOFTWARE IS LICENSED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AND ANY WARRANTY OF NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THIS SOFTWARE MAY BE REDISTRIBUTED TO OTHERS ONLY BY EFFECTIVELY USING THIS OR ANOTHER EQUIVALENT DISCLAIMER IN ADDITION TO ANY OTHER REQUIRED LICENSE TERMS.