diff --git a/meteor/meteor-tests.ts b/meteor/meteor-tests.ts
index 23dbff7362..4cdbd8367e 100644
--- a/meteor/meteor-tests.ts
+++ b/meteor/meteor-tests.ts
@@ -1,4 +1,4 @@
-///
+///
/**
* All code below was copied from the examples at http://docs.meteor.com/.
@@ -98,7 +98,7 @@ Tracker.autorun(function () {
});
console.log("Current room has " +
- Counts.findOne(Session.get("roomId")).count +
+ Counts.find(Session.get("roomId")).count +
" messages.");
/**
@@ -144,8 +144,15 @@ var result = Meteor.call('foo', 1, 2);
* From Collections, Mongo.Collection section
*/
// DA: I added the "var" keyword in there
-var Chatrooms = new Mongo.Collection("chatrooms");
-Messages = new Mongo.Collection("messages");
+
+interface ChatroomsDAO {
+ _id?: string;
+}
+interface MessagesDAO {
+ _id?: string;
+}
+var Chatrooms = new Mongo.Collection("chatrooms");
+Messages = new Mongo.Collection("messages");
var myMessages = Messages.find({userId: Session.get('myUserId')}).fetch();
diff --git a/meteor/meteor.d.ts b/meteor/meteor.d.ts
index 50386a9169..a8b024f245 100644
--- a/meteor/meteor.d.ts
+++ b/meteor/meteor.d.ts
@@ -1,15 +1,23 @@
-// Type definitions for Meteor 1.0.3.1
-// Project: http://www.meteor.com/
-// Definitions by: Dave Allen
-// Definitions: https://github.com/borisyankov/DefinitelyTyped
+/**
+ *
+ * Meteor definitions for TypeScript
+ * author - Olivier Refalo - orefalo@yahoo.com
+ * author - David Allen - dave@fullflavedave.com
+ *
+ * Thanks to Sam Hatoum for the base code for auto-generating this file.
+ *
+ * supports Meteor 1.0.2.1
+ *
+ */
/**
* These are the modules and interfaces that can't be automatically generated from the Meteor data.js file
*/
interface EJSON extends JSON {}
-interface Template {
- [templateName: string]: Meteor.Template;
+interface TemplateStatic {
+ new(): Template;
+ [templateName: string]: Meteor.TemplatePage;
}
declare module Match {
@@ -61,12 +69,7 @@ declare module Meteor {
[id:string]:Meteor.EventHandlerFunction;
}
- // Same definition as top-level Template Interface
- interface TemplateBase {
- [templateName: string]: Meteor.Template;
- }
-
- interface Template {
+ interface TemplatePage {
rendered: Function;
created: Function;
destroyed: Function;
@@ -326,12 +329,15 @@ declare module Blaze {
function getData(elementOrView?: HTMLElement | Blaze.View): Object;
function getView(element?: HTMLElement): Blaze.View;
function Template(viewName?: string, renderFunction?: Function): void;
+ interface Template{
+ }
+
function TemplateInstance(view: Blaze.View): void;
- interface TemplateInstance {
- data(): Object;
- view(): Object;
- firstNode(): Object;
- lastNode(): Object;
+ interface TemplateInstance{
+ data: Object;
+ view: Object;
+ firstNode: Object;
+ lastNode: Object;
$(selector: string): Node[];
findAll(selector: string): HTMLElement[];
find(selector?: string): HTMLElement;
@@ -339,6 +345,9 @@ declare module Blaze {
}
function View(name?: string, renderFunction?: Function): void;
+ interface View{
+ }
+
}
declare module Match {
@@ -365,8 +374,8 @@ declare module EJSON {
}): boolean;
function clone(val:T): T;
function CustomType(): void;
- interface CustomType {
- typeName(): string;
+ interface CustomType{
+ typeName(): string;
toJSONValue(): JSON;
clone(): EJSON.CustomType;
equals(other: Object): boolean;
@@ -418,6 +427,9 @@ declare module Meteor {
rootUrl?: string;
}): string;
function Error(error: string, reason?: string, details?: string): void;
+ interface Error{
+ }
+
}
declare module Mongo {
@@ -426,8 +438,8 @@ declare module Mongo {
idGeneration?: string;
transform?: Function;
}): void;
- interface Collection {
- insert(doc: Object, callback?: Function): string;
+ interface Collection{
+ insert(doc: Object, callback?: Function): string;
update(selector: Mongo.Selector, modifier: Mongo.Modifier, options?: {
multi?: boolean;
upsert?: Boolean;
@@ -468,9 +480,12 @@ declare module Mongo {
}
function ObjectID(hexString: string): void;
+ interface ObjectID{
+ }
+
function Cursor(): void;
- interface Cursor {
- forEach(callback: Function, thisArg?: any): void;
+ interface Cursor{
+ forEach(callback: Function, thisArg?: any): void;
map(callback: Function, thisArg?: any): void;
fetch(): Array;
count(): number;
@@ -484,10 +499,10 @@ declare module Tracker {
var active: boolean;
var currentComputation: Tracker.Computation;
function Computation(): void;
- interface Computation {
- stopped(): boolean;
- invalidated(): boolean;
- firstRun(): boolean;
+ interface Computation{
+ stopped: boolean;
+ invalidated: boolean;
+ firstRun: boolean;
onInvalidate(callback: Function): void;
invalidate(): void;
stop(): void;
@@ -499,8 +514,8 @@ declare module Tracker {
function onInvalidate(callback: Function): void;
function afterFlush(callback: Function): void;
function Dependency(): void;
- interface Dependency {
- depend(fromComputation?: Tracker.Computation): boolean
+ interface Dependency{
+ depend(fromComputation?: Tracker.Computation): boolean
changed(): void;
hasDependents(): boolean
}
@@ -594,79 +609,80 @@ declare module Email {
}
declare function Subscription(): void;
-declare module Subscription {
- var connection: Meteor.Connection;
- var userId: string;
- function error(error: Error): void;
- function stop(): void;
- function onStop(func: Function): void;
- function added(collection: string, id: string, fields: Object): void;
- function changed(collection: string, id: string, fields: Object): void;
- function removed(collection: string, id: string): void;
- function ready(): void;
+interface Subscription{
+ connection: Meteor.Connection;
+ userId: string;
+ error(error: Error): void;
+ stop(): void;
+ onStop(func: Function): void;
+ added(collection: string, id: string, fields: Object): void;
+ changed(collection: string, id: string, fields: Object): void;
+ removed(collection: string, id: string): void;
+ ready(): void;
}
-declare function ReactiveVar(initialValue: any, equalsFunc?: (oldVal:any, newVal:any)=>boolean): void;
-declare module ReactiveVar {
- function get(): any;
- function set(newValue: any): void;
+declare function ReactiveVar(initialValue: T, equalsFunc?: Function): void;
+interface ReactiveVar{
+ get(): T;
+ set(newValue: T): void;
}
-declare function Template(): void;
-declare module Template {
- var onCreated; /** TODO: add return value **/
- var onRendered; /** TODO: add return value **/
- var onDestroyed; /** TODO: add return value **/
- var created: Function;
- var rendered: Function;
- var destroyed: Function;
- var body: Meteor.TemplateBase;
- function helpers(helpers:{[id:string]: any}): void;
- function events(eventMap: {[actions: string]: Function}): void;
- function instance(): Blaze.TemplateInstance;
- function currentData(): {};
- function parentData(numLevels?: number): {};
- function registerHelper(name: string, helperFunction: Function): void;
+declare var Template: TemplateStatic;
+// TemplateStatic interface should be defined separately at top with static methods
+interface Template{
+ onCreated: Function;
+ onRendered: Function;
+ onDestroyed: Function;
+ created: Function;
+ rendered: Function;
+ destroyed: Function;
+ body: TemplateStatic;
+ helpers(helpers:{[id:string]: any}): void;
+ events(eventMap: {[actions: string]: Function}): void;
+ instance(): Blaze.TemplateInstance;
+ currentData(): {};
+ parentData(numLevels?: number): {};
+ registerHelper(name: string, helperFunction: Function): void;
}
declare function CompileStep(): void;
-declare module CompileStep {
- var inputSize; /** TODO: add return value **/
- var inputPath; /** TODO: add return value **/
- var fullInputPath; /** TODO: add return value **/
- var pathForSourceMap; /** TODO: add return value **/
- var packageName; /** TODO: add return value **/
- var rootOutputPath; /** TODO: add return value **/
- var arch; /** TODO: add return value **/
- var fileOptions; /** TODO: add return value **/
- var declaredExports; /** TODO: add return value **/
- function read(n?: number); /** TODO: add return value **/
- function addHtml(options: {
+interface CompileStep{
+ inputSize; /** TODO: add return value **/
+ inputPath; /** TODO: add return value **/
+ fullInputPath; /** TODO: add return value **/
+ pathForSourceMap; /** TODO: add return value **/
+ packageName; /** TODO: add return value **/
+ rootOutputPath; /** TODO: add return value **/
+ arch; /** TODO: add return value **/
+ fileOptions; /** TODO: add return value **/
+ declaredExports; /** TODO: add return value **/
+ read(n?: number); /** TODO: add return value **/
+ addHtml(options: {
section?: string;
data?: string;
}); /** TODO: add return value **/
- function addStylesheet(options: {
+ addStylesheet(options: {
}, path: string, data: string, sourceMap: string); /** TODO: add return value **/
- function addJavaScript(options: {
+ addJavaScript(options: {
path?: string;
data?: string;
sourcePath?: string;
}); /** TODO: add return value **/
- function addAsset(options: {
+ addAsset(options: {
}, path: string, data: any /** Buffer **/ | string); /** TODO: add return value **/
- function error(options: {
+ error(options: {
}, message: string, sourcePath?: string, line?: number, func?: string); /** TODO: add return value **/
}
declare function PackageAPI(): void;
-declare module PackageAPI {
- function use(packageNames: string | string[], architecture?: string, options?: {
+interface PackageAPI{
+ use(packageNames: string | string[], architecture?: string, options?: {
weak?: boolean;
unordered?: Boolean;
}): void;
- function imply(packageSpecs: string | string[]): void;
- function addFiles(filename: string | string[], architecture?: string): void;
- function versionsFrom(meteorRelease: string | string[]): void;
- // function export(exportedObject: string, architecture?: string): void;
+ imply(packageSpecs: string | string[]): void;
+ addFiles(filename: string | string[], architecture?: string): void;
+ versionsFrom(meteorRelease: string | string[]): void;
+ export(exportedObject: string, architecture?: string): void;
}