Add types for tableify (#30573)

This commit is contained in:
Emily Marigold Klassen
2018-11-16 16:18:44 -08:00
committed by Pranav Senthilnathan
parent 9b4c987265
commit f1e4894762
4 changed files with 77 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
// Type definitions for tableify 1.1
// Project: https://github.com/wankdanker/node-tableify
// Definitions by: Emily Marigold Klassen <https://github.com/forivall>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
export = tableify;
declare function tableify<T extends Record<string, any>>(
obj: T | ReadonlyArray<T>,
columns?: ReadonlyArray<keyof T> | false,
parents?: any[]
): string;
declare function tableify(obj: any): string;
declare namespace tableify {
interface Config {
classes?: boolean;
classPrefix?: string;
}
function defaults(config: Config): {
<T extends Record<string, any>>(
obj: T | ReadonlyArray<T>,
columns?: ReadonlyArray<keyof T> | false,
parents?: any[]
): string;
(obj: any): string;
};
}
+25
View File
@@ -0,0 +1,25 @@
import tableify = require('tableify');
const html = tableify({
someArrayOfObjects: [
{a: 1, b: 2, c: 3}
, {a: 2, b: 3, c: 4}
, {a: 3, b: 4, c: 5}
]
, someObject: {
key1: 'value1'
, someArray: [
'value2'
, 'value3'
, 'value4'
, 'value5'
]
, someArrayOfObjects: [
{key2: 123}
, {key2: 234}
, {key2: 345}
]
}
});
html;
+23
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",
"tableify-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }