Skip to content

Commit

Permalink
fix(types): support sweetalert2 modules from dist and src folders (#1693
Browse files Browse the repository at this point in the history
  • Loading branch information
limonte committed Aug 2, 2019
1 parent 1519a05 commit ca1cbe9
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -103,7 +103,7 @@
"check:qunit:minified": "karma start karma.conf.js --single-run --minified",
"check:qunit:sauce": "karma start karma.conf.js --single-run --sauce",
"check:qunit:minified:sauce": "karma start karma.conf.js --single-run --minified --sauce",
"check:ts": "tsc --lib dom,es6 sweetalert2.d.ts",
"check:ts": "tsc --lib dom,es6 --noEmit test/ts/simple-usage.ts sweetalert2.d.ts && tsc --lib dom,es6 --noEmit test/ts/dist-sweetalert2.ts sweetalert2.d.ts && tsc --lib dom,es6 --noEmit test/ts/src-sweetalert2.ts sweetalert2.d.ts",
"check:third-party": "npm run check:unpkg && npm run check:jsdelivr && npm run check:wappalyzer",
"check:wappalyzer": "curl 'https://api.wappalyzer.com/lookup-basic/v1/?url=https%3A%2F%2Fsweetalert2.github.io' 2>&1 | grep --quiet 'SweetAlert2'",
"check:unpkg": "curl --location 'https://unpkg.com/sweetalert2' 2>&1 | grep --quiet 'this.Swal'",
Expand Down
14 changes: 13 additions & 1 deletion sweetalert2.d.ts
Expand Up @@ -20,7 +20,7 @@ declare module 'sweetalert2' {
* import Swal from 'sweetalert2';
* Swal.fire('The Internet?', 'That thing is still around?', 'question');
*/
function fire(title: string, message?: string, type?: SweetAlertType): Promise<SweetAlertResult>;
function fire(title?: string, message?: string, type?: SweetAlertType): Promise<SweetAlertResult>;

/**
* Function to display a SweetAlert2 modal, with an object of options, all being optional.
Expand Down Expand Up @@ -902,6 +902,18 @@ declare module 'sweetalert2' {
export default Swal
}

declare module 'sweetalert2/*/sweetalert2.js' {
export * from 'sweetalert2'
// "export *" does not matches the default export, so do it explicitly.
export { default } from 'sweetalert2' // eslint-disable-line
}

declare module 'sweetalert2/*/sweetalert2.all.js' {
export * from 'sweetalert2'
// "export *" does not matches the default export, so do it explicitly.
export { default } from 'sweetalert2' // eslint-disable-line
}

/**
* These interfaces aren't provided by SweetAlert2, but its definitions use them.
* They will be merged with 'true' definitions.
Expand Down
3 changes: 3 additions & 0 deletions test/ts/dist-sweetalert2.ts
@@ -0,0 +1,3 @@
import Swal from 'sweetalert2/dist/sweetalert2.js'

Swal.fire()
3 changes: 3 additions & 0 deletions test/ts/simple-usage.ts
@@ -0,0 +1,3 @@
import Swal from 'sweetalert2'

Swal.fire()
3 changes: 3 additions & 0 deletions test/ts/src-sweetalert2.ts
@@ -0,0 +1,3 @@
import Swal from 'sweetalert2/src/sweetalert2.js'

Swal.fire()

0 comments on commit ca1cbe9

Please sign in to comment.