mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Type file and tests for gsheets (#44035)
This commit is contained in:
parent
00e2f3a579
commit
9c865209c8
5
types/gsheets/gsheets-tests.ts
Normal file
5
types/gsheets/gsheets-tests.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import * as gsheets from 'gsheets';
|
||||
|
||||
gsheets.getSpreadsheet(''); // $ExpectType Promise<Spreadsheet>
|
||||
gsheets.getWorksheet('', ''); // $ExpectType Promise<Worksheet>
|
||||
gsheets.getWorksheetById('', ''); // $ExpectType Promise<WorksheetFromId>
|
||||
122
types/gsheets/index.d.ts
vendored
Normal file
122
types/gsheets/index.d.ts
vendored
Normal file
@ -0,0 +1,122 @@
|
||||
// Type definitions for gsheets 2.0
|
||||
// Project: https://github.com/interactivethings/gsheets
|
||||
// Definitions by: Kyle Nazario <https://github.com/kyle-n>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/*
|
||||
* - Numeric cells are converted to numbers
|
||||
* - Empty cells are converted to `null`
|
||||
* - Beware of cells formatted as dates! Their values will be returned as Excel-style
|
||||
* [DATEVALUE](http://office.microsoft.com/en-001/excel-help/datevalue-function-HP010062284.aspx) numbers (i.e.
|
||||
* based on the number of days since January 1, 1900)
|
||||
*/
|
||||
export interface Row {
|
||||
[headerColName: string]: string | number | null;
|
||||
}
|
||||
|
||||
/*
|
||||
* - Empty rows are omitted
|
||||
* - `updated` is an ISO-formatted date string
|
||||
*/
|
||||
export interface Worksheet {
|
||||
updated: string;
|
||||
title: string;
|
||||
data: Row[] | null;
|
||||
}
|
||||
|
||||
/*
|
||||
* - Empty rows are omitted
|
||||
* - `updated` is an ISO-formatted date string
|
||||
*/
|
||||
export interface WorksheetFromId extends Worksheet {
|
||||
data: Row[];
|
||||
}
|
||||
|
||||
/*
|
||||
* - `updated` is an ISO-formatted date string
|
||||
*/
|
||||
export interface Spreadsheet {
|
||||
updated: string;
|
||||
title: string;
|
||||
worksheets: Array<{
|
||||
id: string;
|
||||
title: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the contents of a worksheet, specified by its title. Note that this generates
|
||||
* **two** requests (to resolve a worksheet's title). If you know a worksheet's ID (e.g. via a previous call to
|
||||
* `getSpreadsheet`), use `getWorksheetById`.
|
||||
*
|
||||
* For empty worksheets `data` is `null`.
|
||||
*
|
||||
* ---
|
||||
*
|
||||
* Example response:
|
||||
*
|
||||
* ```
|
||||
* {
|
||||
* "updated": "2014-11-19T10:20:18.068Z",
|
||||
* "title": "foobar",
|
||||
* "data": [
|
||||
* {
|
||||
* "foo": "bar",
|
||||
* "baz": 42,
|
||||
* "boing": null
|
||||
* },
|
||||
* // more rows ...
|
||||
* ]
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export function getWorksheet(spreadsheetId: string, worksheetTitle: string): Promise<Worksheet>;
|
||||
|
||||
/*
|
||||
* Returns the contents of a worksheet, specified by its ID.
|
||||
*
|
||||
* For empty worksheets `data` is `[]`.
|
||||
*
|
||||
* ---
|
||||
*
|
||||
* Example response:
|
||||
*
|
||||
* ```
|
||||
* {
|
||||
* "updated": "2014-11-19T10:20:18.068Z",
|
||||
* "title": "foobar",
|
||||
* "data": [
|
||||
* {
|
||||
* "foo": "bar",
|
||||
* "baz": 42,
|
||||
* "boing": null
|
||||
* },
|
||||
* // more rows ...
|
||||
* ]
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export function getWorksheetById(spreadsheetId: string, worksheetId: string): Promise<WorksheetFromId>;
|
||||
|
||||
/*
|
||||
* Returns information about a spreadsheet including a list of worksheets.
|
||||
*
|
||||
* ---
|
||||
*
|
||||
* Example response:
|
||||
*
|
||||
* ```
|
||||
* {
|
||||
* "updated": "2014-11-19T10:20:18.068Z",
|
||||
* "title": "My Awesome Spreadsheet",
|
||||
* "worksheets": [
|
||||
* {
|
||||
* "id": "od6",
|
||||
* "title": "foobar"
|
||||
* },
|
||||
* // more worksheets ...
|
||||
* ]
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export function getSpreadsheet(spreadsheetId: string): Promise<Spreadsheet>;
|
||||
23
types/gsheets/tsconfig.json
Normal file
23
types/gsheets/tsconfig.json
Normal file
@ -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",
|
||||
"gsheets-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/gsheets/tslint.json
Normal file
1
types/gsheets/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user