Merge pull request #32575 from sebastianvera/add-mapbox-s3urls

Add type definitions for @mapbox/s3urls
This commit is contained in:
Pranav Senthilnathan
2019-01-31 12:20:33 -08:00
committed by GitHub
4 changed files with 68 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
// Type definitions for mapbox__s3urls 1.5
// Project: https://github.com/mapbox/s3urls
// Definitions by: Sebastian Vera <https://github.com/sebastianvera>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// tslint:disable-next-line no-single-declare-module
declare module "@mapbox/s3urls" {
function fromUrl(
url: string
): { Bucket: string | undefined; Key: string | undefined };
function toUrl(
bucket: string,
key: string
): {
s3: string;
"bucket-in-path": string;
"bucket-in-host": string;
};
function convert(
url: string,
to: "s3" | "bucket-in-path" | "bucket-in-host"
): string;
function signed(
url: string,
expires: number,
cb: (err: Error | undefined, url: string) => void
): void;
function valid(url: string): boolean;
}
@@ -0,0 +1,15 @@
import * as s3urls from "@mapbox/s3urls";
s3urls.toUrl("bucket", "key"); // $ExpectType { s3: string; "bucket-in-path": string; "bucket-in-host": string; }
s3urls.toUrl("bucket", "key")["s3"]; // $ExpectType string
s3urls.toUrl("bucket", "key")["bucket-in-host"]; // $ExpectType string
s3urls.toUrl("bucket", "key")["bucket-in-path"]; // $ExpectType string
s3urls.valid("s3://bucket/key"); // $ExpectType boolean
s3urls.valid("invalid"); // $ExpectType boolean
s3urls.convert("s3://bucket/key", "s3"); // $ExpectType string
s3urls.convert("s3://bucket/key", "bucket-in-path"); // $ExpectType string
s3urls.convert("s3://bucket/key", "bucket-in-host"); // $ExpectType string
s3urls.fromUrl("s3://bucket/key"); // $ExpectType object
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"paths": {
"@mapbox/s3urls": ["mapbox__s3urls"]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": ["index.d.ts", "mapbox__s3urls-tests.ts"]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }