Skip to content

Commit

Permalink
feat: generate typings (#473)
Browse files Browse the repository at this point in the history
* feat: generate typings

* fix: do not change type of init

* chore: remove source map from repo

* chore: remove not needed type cast

* fix: rebuild package-lock.json with npm 6

* chore: reset CHANGELOG.md to master
  • Loading branch information
andipaetzold authored Jan 13, 2021
1 parent 219b49c commit 1c9a69b
Show file tree
Hide file tree
Showing 13 changed files with 177 additions and 252 deletions.
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
/.idea
/mochawesome-report
/.DS_Store
/dist/cf-extension-api.js
/dist/cf-extension-api.js.map
typings.d.ts
/dist
!/dist/cf-extension.css
!/dist/README.md
!/dist/WARNING.txt
/test/cypress/reports
/test/cypress/videos
/test/cypress/screenshots
Expand Down
1 change: 0 additions & 1 deletion dist/cf-extension-api.js.map

This file was deleted.

16 changes: 10 additions & 6 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import createInitializer from './initialize'
import createAPI from './api'
import locations from './locations'
import { KnownSDK } from './types'

// `export = {}` to allow direct CommonJS `require()` instead of `require().default`
export = {
init: createInitializer(window, createAPI),
locations,
}
export * from './types'
export { default as locations } from './locations'

type Init = <T extends KnownSDK = KnownSDK>(
initCallback: (sdk: T) => any,
options?: { supressIframeWarning?: boolean }
) => void

export const init = createInitializer(window, createAPI) as Init
3 changes: 1 addition & 2 deletions lib/initialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ Learn more about local development with the ui-extension-sdk here:

let customApi
if (typeof makeCustomApi === 'function') {
// Reason for the typecast: https://github.com/microsoft/TypeScript/issues/14889
customApi = (makeCustomApi as any)(channel, params)
customApi = makeCustomApi(channel, params)
}

// Handle pending incoming messages.
Expand Down
9 changes: 0 additions & 9 deletions module-declaration.d.ts

This file was deleted.

Loading

0 comments on commit 1c9a69b

Please sign in to comment.