add definitions for serialize-javascript, detect-port, and react-router-config. updated react-helmet

This commit is contained in:
François Nguyen
2017-03-25 05:15:00 +01:00
parent 508b2e7869
commit 8e1d6e2919
17 changed files with 491 additions and 59 deletions
+29
View File
@@ -0,0 +1,29 @@
// Type definitions for serialize-javascript 1.3
// Project: https://github.com/yahoo/serialize-javascript
// Definitions by: François Nguyen <https://github.com/lith-light-g>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace serializeJavascript {
interface SerializeJSOptions {
/**
* This option is the same as the space argument that can be passed to JSON.stringify.
* It can be used to add whitespace and indentation to the serialized output to make it more readable.
*/
space?: string | number | undefined;
/**
* This option is a signal to serialize() that the object being serialized does not contain any function or regexps values.
* This enables a hot-path that allows serialization to be over 3x faster.
* If you're serializing a lot of data, and know its pure JSON, then you can enable this option for a speed-up.
*/
isJSON?: boolean;
}
}
/**
* Serialize JavaScript to a superset of JSON that includes regular expressions and functions.
* @param {any} input data to serialize
* @param {serializeJavascript.SerializeJSOptions} options optional object
* @returns {string} serialized data
*/
declare function serializeJavascript(input: any, options?: serializeJavascript.SerializeJSOptions): string;
export = serializeJavascript;
@@ -0,0 +1,19 @@
import * as serialize from "serialize-javascript";
const obj: any = {
str: "string",
num: 0,
obj: { foo: "foo" },
arr: [1, 2, 3],
bool: true,
nil: null,
undef: undefined,
fn: function echo(arg: any) { return arg; },
re: /([^\s]+)/g
};
serialize(obj);
serialize(obj, { space: 2 });
serialize(obj, { space: "\t" });
serialize(obj, { isJSON: true });
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"serialize-javascript-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }