Skip to content

Commit

Permalink
Exporting types as recommended (DefinitelyTyped#20441)
Browse files Browse the repository at this point in the history
* correct exports

* updated tests

* lint fixes
  • Loading branch information
matjanos authored and weswigham committed Oct 10, 2017
1 parent 688500f commit 9af7747
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 27 deletions.
33 changes: 15 additions & 18 deletions types/rivets/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Type definitions for rivets
// Type definitions for rivets 0.9
// Project: http://rivetsjs.com/
// Definitions by: Trevor Baron <https://github.com/TrevorDev>
// Definitions by: Trevor Baron <https://github.com/TrevorDev>
// Jakub Matjanowski <https://github.com/matjanos>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3

/// <reference types="jquery" />

declare namespace Rivets {

export namespace Rivets {
interface View {
build(): void;
bind(): void;
Expand All @@ -16,22 +16,22 @@ declare namespace Rivets {

interface Rivets {
// Global binders.
binders: Object;
binders: object;

// Global components.
components: Object;
components: object;

// Global formatters.
formatters: Object;
formatters: object;

// Global sightglass adapters.
adapters: Object;
adapters: object;

// Default attribute prefix.
prefix: string;

// Default template delimiters.
templateDelimiters: Array<string>;
templateDelimiters: string[];

// Default sightglass root interface.
rootInterface: string;
Expand All @@ -42,27 +42,24 @@ declare namespace Rivets {
handler(context: any, ev: Event, biding: any): void;

configure(options?: {

// Attribute prefix in templates
prefix?: string;

//Preload templates with initial data on bind
// Preload templates with initial data on bind
preloadData?: boolean;

//Root sightglass interface for keypaths
// Root sightglass interface for keypaths
rootInterface?: string;

// Template delimiters for text bindings
templateDelimiters?: Array<string>
templateDelimiters?: string[]

// Augment the event handler of the on-* binder
handler?: Function;
handler?(context: any, ev: Event, biding: any): void;
}): void;

bind(element: HTMLElement, models: Object, options?: Object): View;
bind(element: JQuery, models: Object, options?: Object): View;
bind(element: Array<HTMLElement>, models: Object, options?: Object): View;
bind(element: HTMLElement | HTMLElement[] | JQuery, models: object, options?: object): View;
}
}

declare var rivets: Rivets.Rivets;
export const Rivets: Rivets.Rivets;
18 changes: 9 additions & 9 deletions types/rivets/rivets-tests.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Rivets } from 'rivets';


rivets.configure({
Rivets.configure({
// Attribute prefix in templates
prefix: 'rv',
// Preload templates with initial data on bind
Expand All @@ -10,13 +10,13 @@ rivets.configure({
// Template delimiters for text bindings
templateDelimiters: ['[[', ']]'],
// Augment the event handler of the on-* binder
handler: function(target:any, event:any, binding:any) {
this.call(target, event, binding.view.models)
handler: (target: any, event: any, binding: any) => {
this.call(target, event, binding.view.models);
}
});

var t = {test: ["hello", "one", "two"]}
var opts = {bar: "foo"};
rivets.bind(document.getElementById("para1"), t);
rivets.bind(document.getElementById("para1"), t, opts);
rivets.bind([document.getElementById("para1"), document.getElementById("para2")], t);
const t = { test: ["hello", "one", "two"] };
const opts = { bar: "foo" };
Rivets.bind(document.getElementById("para1"), t);
Rivets.bind(document.getElementById("para1"), t, opts);
Rivets.bind([document.getElementById("para1"), document.getElementById("para2")], t);
1 change: 1 addition & 0 deletions types/rivets/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

0 comments on commit 9af7747

Please sign in to comment.