Skip to content

Add more exported types #171

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

Closed
wants to merge 1 commit into from
Closed

Conversation

Chroscielski
Copy link

Current types exported via index.ts have some missing types if you want to strongly type everything in the code using durable functions to benefit from intellisense. I have added what has been missing from my point of view (I have manually imported that types from src directory in my current solution).

Example typing (df was not visible by intellisense previously):

const orchestratorTrigger: (ctx: IOrchestrationFunctionContext) => void =
  orchestrator(function* f(ctx: IOrchestrationFunctionContext): IterableIterator<unknown> {
    const message: ICommandMessage = ctx.df.getInput() as ICommandMessage;
}

@davidmrdavid davidmrdavid self-requested a review April 21, 2020 00:02
@davidmrdavid
Copy link
Collaborator

davidmrdavid commented Apr 21, 2020

Hi @Chroscielski , thank you for your contribution! ⚡

Your PR caught my eye as we're looking to provide better type hints and IntelliSense for our TypeScript users. A few questions:

  • Do you mind sharing a little bit more context around your snippet?
  • Where is ICommandMessage coming from?
  • If possible, do you have a few more instances of strong typing snippets that you'd like to have available but currently do not work out of the box? Just trying to add them to our testers.

Thanks! Just trying to gather a few more testing scenarios before trying to merge.

@Chroscielski
Copy link
Author

Hi @davidmrdavid, thanks for checking out my contribution! ⚡

  • My snippet is just an example of the orchestrator function with strongly typed IOrchestrationFunctionContext, since it was not exported and we had our tslint very restrictive about typing everything (and not using any). Additionally it has impact on the comfort of writing the orchestrator itself, since its context is more specific than usual functions context. In our case the code does much more than just getting the input of course, but I wanted to provide some short overview on why I would like to have the type exported.
  • iCommand is our project internal type, since we are expecting to receive a well-known structure, based on which we invoke suitable logic. Some more context: I have used durable functions with my team to integrate external data providers (different APIs) with our system and based on the command we are either getting data from all providers or just invoking some specific logic for previously selected one. That's why we need some metadata along with requests.
  • These were only ones bothering me for now, but I'm more than happy to provide more in another merge request if I'll find some more :)

I hope it's helpful. Do not hesitate to ask more if something is unclear or you have some more questions.

@davidmrdavid
Copy link
Collaborator

davidmrdavid commented May 5, 2020

Thanks for your feedback @Chroscielski.
Interesting, I had not thought of the impact of 'nesting' the orchestration definition within the trigger. I wonder if more of our TypeScript users leverage that pattern. I'll follow-up with the rest of the team to give this some thought.

In any case, I do want to confirm to you that we're embarking on designing a better TypeScript experience by being more cognizant of what types we export and what docs get picked up by IntelliSense. As a result, I'll put the brakes on merging this PR for now, as we're still designing these changes and we want to figure out where this would fit in all that. In a few weeks time though, I'll put some pressure into merging this in one way or another.

Some of those efforts have already started in this PR: #185
and, in the coming months, I expect that PR to grow in scope from its current simple change to the larger refactoring we've been talking about. It'll just take a bit to get there!

I'll probably reach out again!

@Chroscielski Chroscielski deleted the ExtendTypings branch August 3, 2024 18:29
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.

2 participants