ngneat / dialog

👻 A simple to use, highly customizable, and powerful modal for Angular Applications
https://ngneat.github.io/dialog/
MIT License
394 stars 38 forks source link

possibly undefined values inside dialog component leads to: error TS2769: No overload matches this call #81

Closed mrs-cp closed 1 year ago

mrs-cp commented 1 year ago

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

If a DialogComponent contains possibly undefined values, error TS2769: No overload matches this callget's thrown inside the component that triggers the opening of the DialogComponent

Example to reproduce error:

export class BlablaDialogComponent implements OnInit {
  ...
  creator?: CreatorDTO;

  constructor(
    private dialogRef: DialogRef<{processId: number}>
  ) { }

  ngOnInit(): void {
    this.api.getCreator(this.processId).subscribe({
       next: response => {
        this.creator = response.creator;
      },
      error: (error: HttpErrorResponse) => ...
    });
  }

error thrown here inside the component(s) triggering the dialog:

  openDialog(): void {
    this.dialogService.open(BlablaDialogComponent, {
      data: {
        processId: this.processId
      },
      minHeight: '0px',
      enableClose: false,
    });
  }

The problem is this part inside the BlablaDialogComponent: creator?: CreatorDTO. If I do not define it as possibly undefined, the error disappears. However, it is possibly undefined 😄 .

Expected behavior

undefined values (like creator?: CreatorDTO in the example) inside dialog components should be possible and not lead to errors

see example

Environment


Angular version: 15.0.3
ngneat/dialog: 3.0.1

Browser:
- [x] Chrome (desktop) version 108.0.5359.98
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX

For Tooling issues:
- Node version: v18.12.1
- Platform:  Mac

Others:

NetanelBasal commented 1 year ago

Can you try the inject version, please?

mrs-cp commented 1 year ago

no change, unfortunately :(

NetanelBasal commented 1 year ago

Screenshot 2022-12-12 at 15 28 04

NetanelBasal commented 1 year ago

I don't have any errors. Can you reproduce it in our playground?

https://github.com/ngneat/dialog/tree/master/src/app

mrs-cp commented 1 year ago

hi, already had a separate project to check if there is anything else interfering with the dialog inside our project (but no 😢 ), just quickly pushed that one and sent you an invite: https://github.com/mrs-cp/ngneat

error msg inside the test-project: Bildschirmfoto 2022-12-12 um 16 38 02

NetanelBasal commented 1 year ago

It should be fine now.

mrs-cp commented 1 year ago

Thank you! 🎉 🥳