[changelog-parser] Add typing for changelog-parser (#34137)

* Added type defs for changelog-parser

* Updated jsdoc comments

* Corrected callback return type

Added Partial<Options>
This commit is contained in:
Adam Zerella
2019-03-26 03:55:55 +11:00
committed by timolinn
parent 69176140e8
commit b446b9a64f
4 changed files with 64 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
import parseChangelog = require('changelog-parser');
const options = {
filePath: 'path/to/CHANGELOG.md',
removeMarkdown: false
};
parseChangelog({filePath: 'path/to/CHANGELOG.md'}, (result, error) => {});
parseChangelog(options, (result, error) => {});
parseChangelog({filePath: 'path/to/CHANGELOG.md'}, (result) => {});
parseChangelog(options);
parseChangelog('path/to/CHANGELOG.md');

24
types/changelog-parser/index.d.ts vendored Normal file
View File

@@ -0,0 +1,24 @@
// Type definitions for changelog-parser 2.7
// Project: https://github.com/hypermodules/changelog-parser
// Definitions by: Adam Zerella <https://github.com/adamzerella>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
interface Options {
/**
* Path to changelog file.
*/
filePath: string;
/**
* Removes the markdown markup from the changelog entries by default.
* You can change its value to false to keep the markdown.
*/
removeMarkdown: boolean;
}
/**
* Change log parser for node.
*/
declare function parseChangelog(options: Partial<Options>|string, callback?: (result: object, error: string|null) => void): Promise<object>;
export = parseChangelog;

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"changelog-parser-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }