Skip to content

Commit

Permalink
Merge pull request #169 from cspotcode/ts-declarations
Browse files Browse the repository at this point in the history
Add TypeScript declarations
  • Loading branch information
amwmedia authored Oct 16, 2019
2 parents 0224055 + 51b7edd commit 2de27bf
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,29 @@ Method | Parameters | Returns | Description
[**setPrompt**](#setprompt) | *String, InquirerPrompt* | | registers a custom prompt type with inquirer
[**load**](https://github.com/amwmedia/plop/blob/master/plop-load.md) | *Array[String], Object, Object* | | loads generators, helpers and/or partials from another plopfile or npm module

### TypeScript declarations

`plop` and `node-plop` bundle TypeScript declarations. Whether or not you write your plopfile in TypeScript, many
editors will offer code assistance via these declarations.

```typescript
// plopfile.ts
import {NodePlopAPI} from 'plop';

export default function (plop: NodePlopAPI) {
};
```

```javascript
// plopfile.js

exports.default = function (
/** @type {import('plop').NodePlopAPI} */
plop
) {
};
```

## setHelper
`setHelper` directly corresponds to the handlebars method `registerHelper`. So if you are familiar with [handlebars helpers](http://handlebarsjs.com/expressions.html#helpers), then you already know how this works.

Expand Down Expand Up @@ -241,7 +264,7 @@ Property | Type | Default | Description
**actions** | *Array[[ActionConfig](#interface-actionconfig)]* | | actions to perform

> If your list of actions needs to be dynamic, take a look at [using a dynamic actions array.](#using-a-dynamic-actions-array)
### *Interface* `ActionConfig`
The following properties are the standard properties that plop handles internally. Other properties will be required depending on the *type* of action. Also take a look at the [built-in actions](#built-in-actions).

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "plop",
"version": "2.5.0",
"description": "Micro-generator framework that makes it easy for an entire team to create files with a level of uniformity",
"main": "./src/plop.js",
"main": "./src/plop",
"repository": {
"type": "git",
"url": "https://github.com/amwmedia/plop.git"
Expand Down
11 changes: 11 additions & 0 deletions src/plop.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export {
ActionConfig,
ActionType,
AddActionConfig,
AddManyActionConfig,
AppendActionConfig,
CustomActionFunction,
ModifyActionConfig,
PlopCfg,
PlopGenerator
} from 'node-plop';

0 comments on commit 2de27bf

Please sign in to comment.