Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

Commit

Permalink
Add prebuild script and tsconfig to generate declarations (#125)
Browse files Browse the repository at this point in the history
* Add prebuild script and tsconfig to generate declarations

* Add 'types' key to package.json
  • Loading branch information
nathanhleung authored and chuckcarpenter committed Nov 25, 2019
1 parent 1570744 commit d74736d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"main": "dist/Shepherd.js",
"module": "dist/Shepherd.es.js",
"jsnext:main": "dist/Shepherd.es.js",
"types": "dist/index.d.ts",
"homepage": "https://shipshapecode.github.io/react-shepherd/",
"engines": {
"node": ">=8",
Expand All @@ -15,6 +16,7 @@
"scripts": {
"test": "cross-env CI=1 react-scripts test",
"test:watch": "react-scripts test",
"prebuild": "tsc --project ./tsconfig-declarations.json",
"build": "rollup -c",
"start": "rollup -c -w",
"prepare": "yarn run build",
Expand Down
4 changes: 3 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ const addSteps = (steps: Array<Step> | Array<Step.StepOptions>, tour: Tour) => {
step.buttons = buttons.map((button: ShepherdStepWithType) => {
const { type, classes, text, action } = button;
return {
action: action || tour[type],
// TypeScript doesn't have great support for dynamic method calls with
// bracket notation, so we use the `any` escape hatch
action: action || (tour as any)[type!],
classes,
text,
type
Expand Down
9 changes: 9 additions & 0 deletions tsconfig-declarations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"isolatedModules": false,
"noEmit": false,
"declaration": true,
"emitDeclarationOnly": true
}
}

0 comments on commit d74736d

Please sign in to comment.