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

fix(modal): readd modal generic with a fix for noImplicitAny #3578

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

gentoo90
Copy link
Contributor

@gentoo90 gentoo90 commented Feb 9, 2020

Before submitting a pull request, please make sure you have at least performed the following:

  • read and followed the CONTRIBUTING.md guide.
  • built and tested the changes locally.
  • added/updated any applicable tests.
  • added/updated any applicable API documentation.
  • added/updated any applicable demos.

Another attempt on #2479.
Pullrequest #2815 was rolled back because of a bug with noImplicitAny (#3464).
In this request I'm putting it back with one addition: modal is now passed as an argument into beforeDismiss, which allows to write

const modalRef = this.modalService.open(NgbdModalContent, {
  beforeDismiss: modal => modal.componentInstance.canDismiss(),
});

which compiles correctly without any additional type annotations.

CC @nseni , @michaeljota

@codecov-io
Copy link

Codecov Report

Merging #3578 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3578   +/-   ##
=======================================
  Coverage   91.71%   91.71%           
=======================================
  Files         100      100           
  Lines        2896     2896           
  Branches      533      533           
=======================================
  Hits         2656     2656           
  Misses        183      183           
  Partials       57       57
Flag Coverage Δ
#e2e 56.59% <100%> (ø) ⬆️
#unit 88.49% <100%> (ø) ⬆️
Impacted Files Coverage Δ
src/modal/modal-config.ts 100% <ø> (ø) ⬆️
src/modal/modal.ts 100% <100%> (ø) ⬆️
src/modal/modal-ref.ts 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 686fbd5...caed7d0. Read the comment docs.

@gentoo90 gentoo90 changed the title Readd modal generic with a fix for noImplicitAny fix(modal): readd modal generic with a fix for noImplicitAny Mar 26, 2020
@gethari
Copy link

gethari commented Jan 19, 2021

any chance this is getting merged ? @gentoo90

@tayambamwanza
Copy link

tayambamwanza commented Apr 19, 2021

@gentoo90 @michaeljota While waiting for this is there an alternative way to get the types working?

@gentoo90
Copy link
Contributor Author

@gentoo90 @michaeljota While waiting for this is there an alternative way to get the types working?

Just put componentInstance into a separate variable with type annotation I guess:

const modalRef = this.modalService.open(ModalComponent);
const ci: ModalComponent = modalRef.componentInstance;
ci.name = 'World';

I rebased onto the latest master and fixed compile error in modalRef.componentInstance.

@tayambamwanza
Copy link

@gentoo90 @michaeljota While waiting for this is there an alternative way to get the types working?

Just put componentInstance into a separate variable with type annotation I guess:

const modalRef = this.modalService.open(ModalComponent);
const ci: ModalComponent = modalRef.componentInstance;
ci.name = 'World';

I rebased onto the latest master and fixed compile error in modalRef.componentInstance.

Thanks that works for now.

@Dassderdie
Copy link

Is there any update on this?

@codecov-commenter
Copy link

codecov-commenter commented Jan 30, 2022

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (df17d50) 89.24% compared to head (d3ac0ec) 89.24%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3578   +/-   ##
=======================================
  Coverage   89.24%   89.24%           
=======================================
  Files         120      120           
  Lines        4287     4288    +1     
  Branches      820      820           
=======================================
+ Hits         3826     3827    +1     
  Misses        419      419           
  Partials       42       42           
Flag Coverage Δ
e2e 49.92% <75.00%> (-0.02%) ⬇️
unit 89.87% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/modal/modal-config.ts 75.00% <ø> (ø)
src/modal/modal-ref.ts 100.00% <100.00%> (ø)
src/modal/modal.ts 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

michaeljota and others added 3 commits October 17, 2023 19:28
Typescript demands `undefined` in the return type if function doesn't
return anything. In our case `undefined` is choosen when there's no
component, so we add a little trick to relax that rule.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants