From 94df0f90410364b1fc5ce1cba863a5ac2f6c9a10 Mon Sep 17 00:00:00 2001 From: Matt Traynham Date: Fri, 24 Apr 2015 14:08:07 -0400 Subject: [PATCH 1/2] Colorbrewer definition --- colorbrewer/colorbrewer-tests.ts | 8 ++++ colorbrewer/colorbrewer.d.ts | 76 ++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 colorbrewer/colorbrewer-tests.ts create mode 100644 colorbrewer/colorbrewer.d.ts diff --git a/colorbrewer/colorbrewer-tests.ts b/colorbrewer/colorbrewer-tests.ts new file mode 100644 index 000000000..1e8c835c5 --- /dev/null +++ b/colorbrewer/colorbrewer-tests.ts @@ -0,0 +1,8 @@ +/// + +const accent3: string[] = colorbrewer.Accent[3]; +const accent4: string[] = colorbrewer.Accent[4]; +const accent5: string[] = colorbrewer.Accent[5]; +const accent6: string[] = colorbrewer.Accent[6]; +const accent7: string[] = colorbrewer.Accent[7]; +const accent8: string[] = colorbrewer.Accent[8]; diff --git a/colorbrewer/colorbrewer.d.ts b/colorbrewer/colorbrewer.d.ts new file mode 100644 index 000000000..ecd4bffc7 --- /dev/null +++ b/colorbrewer/colorbrewer.d.ts @@ -0,0 +1,76 @@ +// Type definitions for colorbrewer v1.0.0 +// Project: https://github.com/jeanlauliac/colorbrewer +// Definitions by: Matt Traynham +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare var colorbrewer: ColorBrewer.Base; + +declare module ColorBrewer { + interface ColorScheme { + [n: number]: string[]; + } + + interface EightColorScheme extends ColorScheme { + 3: [string, string, string]; + 4: [string, string, string, string]; + 5: [string, string, string, string, string]; + 6: [string, string, string, string, string, string]; + 7: [string, string, string, string, string, string, string]; + 8: [string, string, string, string, string, string, string, string]; + } + + interface NineColorScheme extends EightColorScheme { + 9: [string, string, string, string, string, string, string, string, string]; + } + + interface ElevenColorScheme extends NineColorScheme { + 10: [string, string, string, string, string, string, string, string, string, string]; + 11: [string, string, string, string, string, string, string, string, string, string, string]; + } + + interface TwelveColorScheme extends ElevenColorScheme { + 12: [string, string, string, string, string, string, string, string, string, string, string, string]; + } + + interface Base { + YlGn: NineColorScheme; + YlGnBu: NineColorScheme; + GnBu: NineColorScheme; + BuGn: NineColorScheme; + PuBuGn: NineColorScheme; + PuBu: NineColorScheme; + BuPu: NineColorScheme; + RdPu: NineColorScheme; + PuRd: NineColorScheme; + OrRd: NineColorScheme; + YlOrRd: NineColorScheme; + YlOrBr: NineColorScheme; + Purples: NineColorScheme; + Blues: NineColorScheme; + Greens: NineColorScheme; + Oranges: NineColorScheme; + Reds: NineColorScheme; + Greys: NineColorScheme; + PuOr: ElevenColorScheme; + BrBG: ElevenColorScheme; + PRGn: ElevenColorScheme; + PiYG: ElevenColorScheme; + RdBu: ElevenColorScheme; + RdGy: ElevenColorScheme; + RdYlBu: ElevenColorScheme; + Spectral: ElevenColorScheme; + RdYlGn: ElevenColorScheme; + Accent: EightColorScheme; + Dark2: EightColorScheme; + Paired: TwelveColorScheme; + Pastel1: NineColorScheme; + Pastel2: EightColorScheme; + Set1: NineColorScheme; + Set2: EightColorScheme; + Set3: TwelveColorScheme; + } +} + +declare module 'colorbrewer' { + export = colorbrewer; +} From ffc616163340248c91dbddc0f5ece3acdc136421 Mon Sep 17 00:00:00 2001 From: Matt Traynham Date: Fri, 24 Apr 2015 14:17:17 -0400 Subject: [PATCH 2/2] Fix tests. 'const' not available --- colorbrewer/colorbrewer-tests.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/colorbrewer/colorbrewer-tests.ts b/colorbrewer/colorbrewer-tests.ts index 1e8c835c5..7e17551b5 100644 --- a/colorbrewer/colorbrewer-tests.ts +++ b/colorbrewer/colorbrewer-tests.ts @@ -1,8 +1,8 @@ /// -const accent3: string[] = colorbrewer.Accent[3]; -const accent4: string[] = colorbrewer.Accent[4]; -const accent5: string[] = colorbrewer.Accent[5]; -const accent6: string[] = colorbrewer.Accent[6]; -const accent7: string[] = colorbrewer.Accent[7]; -const accent8: string[] = colorbrewer.Accent[8]; +var accent3: string[] = colorbrewer.Accent[3]; +var accent4: string[] = colorbrewer.Accent[4]; +var accent5: string[] = colorbrewer.Accent[5]; +var accent6: string[] = colorbrewer.Accent[6]; +var accent7: string[] = colorbrewer.Accent[7]; +var accent8: string[] = colorbrewer.Accent[8];