From bce9beea07833c60ed538193e52041d37153b590 Mon Sep 17 00:00:00 2001 From: Lea Hayes Date: Mon, 7 Mar 2016 23:33:57 +0000 Subject: [PATCH 1/3] Add escape-string-regexp type definition. --- escape-string-regexp/escape-string-regexp-tests.ts | 8 ++++++++ escape-string-regexp/escape-string-regexp.d.ts | 10 ++++++++++ 2 files changed, 18 insertions(+) create mode 100644 escape-string-regexp/escape-string-regexp-tests.ts create mode 100644 escape-string-regexp/escape-string-regexp.d.ts diff --git a/escape-string-regexp/escape-string-regexp-tests.ts b/escape-string-regexp/escape-string-regexp-tests.ts new file mode 100644 index 000000000..28a43e622 --- /dev/null +++ b/escape-string-regexp/escape-string-regexp-tests.ts @@ -0,0 +1,8 @@ +/// + +import escapeStringRegexp from 'escape-string-regexp'; + +var inputString: string = '^abc$'; +var outputString: string; + +outputString = escapeStringRegexp(inputString); diff --git a/escape-string-regexp/escape-string-regexp.d.ts b/escape-string-regexp/escape-string-regexp.d.ts new file mode 100644 index 000000000..628978b26 --- /dev/null +++ b/escape-string-regexp/escape-string-regexp.d.ts @@ -0,0 +1,10 @@ +// Type definitions for escape-string-regexp +// Project: https://github.com/sindresorhus/escape-string-regexp +// Definitions by: kruncher +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "escape-string-regexp" { + + export default function (str: string): string; + +} From 9990c208c8cad3f363434c54789c03fe896cfe53 Mon Sep 17 00:00:00 2001 From: Lea Hayes Date: Tue, 8 Mar 2016 01:08:01 +0000 Subject: [PATCH 2/3] Add format-unicorn type definition. --- format-unicorn/format-unicorn-safe-tests.ts | 11 +++++++++++ format-unicorn/format-unicorn-safe.d.ts | 10 ++++++++++ format-unicorn/format-unicorn-tests.ts | 11 +++++++++++ format-unicorn/format-unicorn.d.ts | 12 ++++++++++++ 4 files changed, 44 insertions(+) create mode 100644 format-unicorn/format-unicorn-safe-tests.ts create mode 100644 format-unicorn/format-unicorn-safe.d.ts create mode 100644 format-unicorn/format-unicorn-tests.ts create mode 100644 format-unicorn/format-unicorn.d.ts diff --git a/format-unicorn/format-unicorn-safe-tests.ts b/format-unicorn/format-unicorn-safe-tests.ts new file mode 100644 index 000000000..fd115c24a --- /dev/null +++ b/format-unicorn/format-unicorn-safe-tests.ts @@ -0,0 +1,11 @@ +/// + +import formatUnicorn from 'format-unicorn/safe'; + +// Safe version +var outputString: string; + +outputString = formatUnicorn('Hello, {name}; you have {favoriteNumber}', { + name: "kruncher", + favoriteNumber: 42 +}); diff --git a/format-unicorn/format-unicorn-safe.d.ts b/format-unicorn/format-unicorn-safe.d.ts new file mode 100644 index 000000000..24d75bd9b --- /dev/null +++ b/format-unicorn/format-unicorn-safe.d.ts @@ -0,0 +1,10 @@ +// Type definitions for format-unicorn +// Project: https://github.com/tallesl/format-unicorn +// Definitions by: kruncher +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module 'format-unicorn/safe' { + + export default function (str: string, replacements: { }): string; + +} diff --git a/format-unicorn/format-unicorn-tests.ts b/format-unicorn/format-unicorn-tests.ts new file mode 100644 index 000000000..e256b65ae --- /dev/null +++ b/format-unicorn/format-unicorn-tests.ts @@ -0,0 +1,11 @@ +/// + +import 'format-unicorn'; + +// Unsafe version +var outputString: string; + +outputString = 'Hello, {name}; you have {favoriteNumber}'.formatUnicorn({ + name: "kruncher", + favoriteNumber: 42 +}); diff --git a/format-unicorn/format-unicorn.d.ts b/format-unicorn/format-unicorn.d.ts new file mode 100644 index 000000000..d1780140f --- /dev/null +++ b/format-unicorn/format-unicorn.d.ts @@ -0,0 +1,12 @@ +// Type definitions for format-unicorn +// Project: https://github.com/tallesl/format-unicorn +// Definitions by: kruncher +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface String { + formatUnicorn(replacements: { }): string; +} + +declare module "format-unicorn" { + +} From c42c54b827256fbbb7f574f476f3928f644da9ea Mon Sep 17 00:00:00 2001 From: Lea Hayes Date: Tue, 8 Mar 2016 01:43:40 +0000 Subject: [PATCH 3/3] Switch to external module import syntax. --- escape-string-regexp/escape-string-regexp-tests.ts | 2 +- escape-string-regexp/escape-string-regexp.d.ts | 8 +++++--- format-unicorn/format-unicorn-safe-tests.ts | 2 +- format-unicorn/format-unicorn-safe.d.ts | 4 +++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/escape-string-regexp/escape-string-regexp-tests.ts b/escape-string-regexp/escape-string-regexp-tests.ts index 28a43e622..0e9e9e54c 100644 --- a/escape-string-regexp/escape-string-regexp-tests.ts +++ b/escape-string-regexp/escape-string-regexp-tests.ts @@ -1,6 +1,6 @@ /// -import escapeStringRegexp from 'escape-string-regexp'; +import escapeStringRegexp = require('escape-string-regexp'); var inputString: string = '^abc$'; var outputString: string; diff --git a/escape-string-regexp/escape-string-regexp.d.ts b/escape-string-regexp/escape-string-regexp.d.ts index 628978b26..74b095823 100644 --- a/escape-string-regexp/escape-string-regexp.d.ts +++ b/escape-string-regexp/escape-string-regexp.d.ts @@ -4,7 +4,9 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module "escape-string-regexp" { - - export default function (str: string): string; - + + function escapeStringRegexp(str: string): string; + + export = escapeStringRegexp; + } diff --git a/format-unicorn/format-unicorn-safe-tests.ts b/format-unicorn/format-unicorn-safe-tests.ts index fd115c24a..e83f2023f 100644 --- a/format-unicorn/format-unicorn-safe-tests.ts +++ b/format-unicorn/format-unicorn-safe-tests.ts @@ -1,6 +1,6 @@ /// -import formatUnicorn from 'format-unicorn/safe'; +import formatUnicorn = require('format-unicorn/safe'); // Safe version var outputString: string; diff --git a/format-unicorn/format-unicorn-safe.d.ts b/format-unicorn/format-unicorn-safe.d.ts index 24d75bd9b..adf3a62db 100644 --- a/format-unicorn/format-unicorn-safe.d.ts +++ b/format-unicorn/format-unicorn-safe.d.ts @@ -5,6 +5,8 @@ declare module 'format-unicorn/safe' { - export default function (str: string, replacements: { }): string; + function formatUnicornSafe(str: string, replacements: { }): string; + + export = formatUnicornSafe; }