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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 馃幐 fix input/output type inference #651

Merged
merged 2 commits into from Mar 21, 2024

Conversation

kfrancois
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[X] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

The following types are not inferred correctly:

  • InputFunction with transform
  • OutputRef

Issue Number: #649

What is the new behavior?

Types are properly inferred when using output() or when using input() with transform set.

Does this PR introduce a breaking change?

[X] Yes
[ ] No

I believe the required peerDependency should now be Angular 17.3.0 - I didn't update this yet but I believe it's necessary (I have not yet checked the behaviour in a repo running an older version)

Other information

Copy link

stackblitz bot commented Mar 20, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@@ -24,7 +24,7 @@ export interface QueryOptions<R> {
parentSelector?: Type<any> | string;
}

export type EventEmitterType<P> = P extends EventEmitter<infer T> ? T : never;
export type OutputType<P> = P extends EventEmitter<infer T> ? T : P extends OutputRef<infer T> ? T : never;
Copy link
Member

Choose a reason for hiding this comment

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

This is a breaking change because it requires a specific version of Angular. I don't mind to release a major version but you should include it in the peer dependency and the commit message

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Understood! I'll push this later today or tomorrow. Thank you for following up so quickly on this 馃槃

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added - it's a shame this type got changed in a minor version, since I do believe semantically it's a breaking change in Angular.

Any conditional types that relied on extends InputSignal broke. I suppose the Angular team considered this as an internal type (or simply forgot about it/thought it wasn't worth the breaking change).

BREAKING CHANGE: using Angular types not available in versions lower
than 17.3.0
@NetanelBasal NetanelBasal merged commit 8cacdda into ngneat:master Mar 21, 2024
3 checks passed
@kfrancois kfrancois deleted the fix-input-output-typing branch April 3, 2024 20:04
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.

None yet

2 participants