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

TypeScript: support sweetalert2 modules in dist and src folders #1693

Merged
merged 4 commits into from Aug 2, 2019

Conversation

limonte
Copy link
Member

@limonte limonte commented Aug 2, 2019

Fixing the issue I described in https://stackoverflow.com/questions/57321486

TLDR: right now import Swal from 'sweetalert2/dist/sweetalert2.js' isn't TS-friendly and producing this error:

Could not find a declaration file for module 'sweetalert2/dist/sweetalert2.js'. 

ts(7016)

This PR is based on @toverux's answer https://stackoverflow.com/a/57323500

@limonte limonte changed the title fix(TS): support sweetalert2 modules in dist and src folders TypeScript: support sweetalert2 modules in dist and src folders Aug 2, 2019
@coveralls
Copy link

coveralls commented Aug 2, 2019

Pull Request Test Coverage Report for Build 5245

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 90.825%

Totals Coverage Status
Change from base Build 5237: 0.0%
Covered Lines: 1303
Relevant Lines: 1379

💛 - Coveralls

@toverux
Copy link
Member

toverux commented Aug 2, 2019

Hah, it's a nice idea to use globs in the .d.ts file to cover both src and dist!
It is also possible to type every .js module in src/ and derive the type of the dist/ files from that, that would be the cleanest and definitive method to do it, however I don't think our customers often use internal symbols and submodules (even src/SweetAlert.js), and therefore this approach may be way too invasive for this particular project.

@limonte limonte force-pushed the fix/ts/support-modules-in-dist-and-src branch 2 times, most recently from a9e19c6 to 80bd6d8 Compare August 2, 2019 12:50
@limonte
Copy link
Member Author

limonte commented Aug 2, 2019

Hah, it's a nice idea to use globs in the .d.ts file to cover both src and dist!

Yup, wildcards are working nicely, I also tried

declare module 'sweetalert2/*/sweetalert2.*js' {

to avoid copy-pasting, but

Pattern 'sweetalert2/*/sweetalert2.*js' can have at most one '*' character.

ts(5061)

Thanks again @toverux for your valuable (as always) input!

@limonte limonte merged commit ca1cbe9 into master Aug 2, 2019
@limonte limonte deleted the fix/ts/support-modules-in-dist-and-src branch August 2, 2019 13:04
limonte pushed a commit that referenced this pull request Aug 2, 2019
## [8.14.1](v8.14.0...v8.14.1) (2019-08-02)

### Bug Fixes

* **types:** support sweetalert2 modules from dist and src folders ([#1693](#1693)) ([ca1cbe9](ca1cbe9))
@limonte
Copy link
Member Author

limonte commented Aug 2, 2019

🎉 This PR is included in version 8.14.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants