Skip to content

Commit

Permalink
Quotesy (#51764)
Browse files Browse the repository at this point in the history
* [quotesy] add types for quotesy 1.0

* [quotesy] clean up doc comments

* add tags and source properties to Quote

Co-authored-by: Nelson <194400+nelsonic@users.noreply.github.com>

* [quotesy] make tags, source optional; update docs

Co-authored-by: Nelson <194400+nelsonic@users.noreply.github.com>
  • Loading branch information
natesilva and nelsonic committed Mar 16, 2021
1 parent 0dbf3cc commit 3711f47
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
32 changes: 32 additions & 0 deletions types/quotesy/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Type definitions for quotesy 1.0
// Project: https://github.com/dwyl/quotes#readme
// Definitions by: Nate Silva <https://github.com/natesilva>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

/**
* Returns an Array of Quote Objects
*/
export function parse_json(): Quote[];

/**
* Returns a random quote from the list
*/
export function random(): Quote;

/**
* Returns a random quote for a specific tag
* @param tag the tag to search for
*/
export function random_by_tag(tag: string): Quote;

/** A single quote from the database */
export interface Quote {
/** The author of the quote */
author: string;
/** The text of the quote */
text: string;
/** Comma-separated list of words associated with the quote */
tags?: string;
/** A URL where the origin of the quote can be verified */
source?: string;
}
5 changes: 5 additions & 0 deletions types/quotesy/quotesy-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import quotesy = require("quotesy");

quotesy.parse_json(); // $ExpectType Quote[]
quotesy.random(); // $ExpectType Quote
quotesy.random_by_tag(""); // $ExpectType Quote
23 changes: 23 additions & 0 deletions types/quotesy/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"quotesy-tests.ts"
]
}
1 change: 1 addition & 0 deletions types/quotesy/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

0 comments on commit 3711f47

Please sign in to comment.