Updated for Meteor 0.9.1

This commit is contained in:
Dave Allen
2014-09-05 15:15:30 -07:00
parent d4f35925c4
commit 14070fd926
3 changed files with 292 additions and 187 deletions
+71 -77
View File
@@ -1,106 +1,100 @@
#Meteor Type Definitions
-------------------------
# Meteor Type Definitions
These definitions are now deprecated. Although they will still work up to Meteor version 0.6.5.1 (and possibly much later), the better way to develop a Meteor app with TypeScript is by installing the [typescript-libs](https://atmosphere.meteor.com/package/typescript-libs) Meteor smart package.
These are the definitions for version 0.9.1 of Meteor. The recommended way to use these definitions in a Meteor application is by installing the
[typescript-libs](https://atmosphere.meteor.com/package/typescript-libs) Meteor smart package. The smart package contains TypeScript definitions for
Meteor, common third-party libraries (e.g. jquery, underscore, d3 etc.), and common smart packages (e.g. iron-router).
For any Meteor installation 0.9.0 or afterwards, install this package with:
$ meteor add typescript-libs
You first need to have (Meteorite)[http://oortcloud.github.io/meteorite/] version and smart package manager. If you don't have it, install it with this command:
- `npm install -g meteorite`
## Usage Overview
For most applications, there are 4 specific steps you will have to take to write your Meteor application in TypeScript using this package:
1. [Reference the definitions] (#usage-type-definition-references)
2. [Declare functions for Templates in a special way] (#usage-templates)
3. [Declare Collections in a special way] (#usage-collections)
4. [Create custom definitions for code you write] (#usage-creating-definitions)
5. [Transpile your .ts files into .js files] (#usage-transpilation)
Once you have installed Meteorite, you can easily install the smart package with this command:
- `mrt install typescript-libs`
- I also recommend installing the Meteor typescript compiler: `mrt install typescript-compiler`
## Usage: Type Definition References
Within any TypeScript file, you can reference the Meteor definition file with this line:
///<reference path="/path/to/packages/typescript-libs/meteor.d.ts" />
The smart packages and documentation for them can be found on [Atmosphere](https://atmosphere.meteor.com):
- [typescript-libs](https://atmosphere.meteor.com/package/typescript-libs)
- [typescript-compiler](https://atmosphere.meteor.com/package/typescript-compiler)
## Usage: Templates
When specifying template functions, you will need to use "bracket notation" instead of "dot notation":
Template['myTemplateName']['rendered'] = function ( ) { ... }
Template['myTemplateName']['helpers']({
foo: function () {
return Session.get("foo");
}
});
Template['myTemplateName']['foo'] = function () {
return Session.get("foo");
};
Using the typescript-libs smart package eliminates the need for the Template and Collections steps listed below, although there
are several new modifications necessary to use typescript-libs (e.g. calling Template['yourTemplate']['helpers'], creating Data Objects).
For "dot" notation, TypeScript requires properties be specified on a variable (but not for bracket notation), and it will throw an error saying "myTemplateName"
does not exist on Template.
Kudos to [Olivier Refalo](https://github.com/orefalo) for developing the smart packages quicker and better than me!
--------------------------
## Usage: Collections
The majority of extra work required to use TypeScript with Meteor is creating and maintaining the collection interfaces. However, doing so also provides the
additional benefit of succinctly documenting collection schema definitions (that are actually enforced).
To define collections, you will need to create an interface representing the collection, and then declare a Collection type variable with that interface type (as a generic):
interface JobDAO {
_id?: string;
name: string;
status?: string;
queuedAt?: string;
}
declare var Jobs: Meteor.Collection<JobDAO>;
Jobs = new Meteor.Collection<JobDAO>('jobs');
#Overview
Finally, any TypeScript file using collections will need to contain a reference at the top pointing to the collection definitions:
In order to effectively write a Meteor app with TypeScript, you will probably need to do these things:
- Reference the Meteor type definitions file (meteor.d.ts)
- Create a Template definition file
- Create Collections within a module or modules
/// <reference path="../packages/typescript-libs/meteor.d.ts"/>
/// <reference path="../packages/typescript-libs/underscore.d.ts"/>
/// <reference path="models/models.ts"/>
##Referencing Meteor type definitions in your app
- Place the meteor.d.ts file in a directory (maybe `<app root dir>/lib/typescript`)
- Add `/// <reference path='../lib/typescript/meteor.d.ts'/>` to the top of any TypeScript file
This will make these typed Meteor variables/objects available across your application:
- Meteor
- Session
- Deps
- Accounts
- Match
- Computation
- Dependency
- EJSON
- HTTO
- Email
- Assets
- DPP
*Please note that the Template variable is not automatically available. You need to follow the instructions below to use the Template variable.*
If you choose to define collections (using the code above) in a separate file (e.g. collections/models/models.ts) and then create a separate file per collection
with the methods and permissions for that collection (e.g. collections/jobs.ts), the collection definitions should be one directory deeper than the collection
method/permission declarations so that Meteor can find the variable declarations before use. (e.g. collections/models/models.ts).
##Defining Templates
In order to call `Template.yourTemplateName.method`, you will need to create a simple TypeScript definition file that declares a Template variable containing a list of template view-models/managers of type IMeteorViewModel (or IMeteorManager, which is the same as IMeteorViewModel). A good place for this definition could be `<app root dir>/client/views/view-model-types.d.ts`. Here is an example of that file:
/// <reference path='../../lib/typescript/meteor.d.ts'/>
declare var Template: {
newPosts: IMeteorViewModel;
bestPosts: IMeteorViewModel;
postsList: IMeteorViewModel;
comment: IMeteorViewModel;
commentSubmit: IMeteorViewModel;
notifications: IMeteorViewModel;
postPage: IMeteorViewModel;
postEdit: IMeteorViewModel;
postItem: IMeteorViewModel;
postNew: IMeteorViewModel;
header: IMeteorViewModel;
}
After you create this file, you may access the Template variable by declaring something similar to `/// <reference path='../view-model-types.d.ts'/>` at the top of any TypeScript file containing references to Template. Something like `Template.postsList.helpers()` would then transpile successfully (and also have the benefits of typing).
## Usage: Creating Definitions
Here is a guide to creating definitions: <http://www.typescriptlang.org/Handbook#writing-dts-files>
##Defining Collections
In TypeScript, global variables are not allowed, and in a Meteor app, creating a local variable (using `var <varName>`) limits a variable's scope to the file. However, you will probably want to define variables, such as collections, that can be used across multiple files. In the case of collections, one way to work around these limitations is to wrap the definitions of all collections within a module, and then make the module globally accessible. Here is an example (collections/models.ts):
module Models {
export var Posts = new Meteor.Collection('posts');
export var Comments = new Meteor.Collection('comments');
export var Notifications = new Meteor.Collection('notifications');
}
## Usage: Transpilation
WebStorm is good TypeScript-aware editor. It can automatically transpile your TypeScript code into JavaScript every time you save a file. To enable this
feature in WebStorm on OSX, first install the TypeScript transpiler on your system:
this.Models = Models;
$ [sudo -H] npm install -g typescript
You can then access the Posts collection by placing something similar to `/// <reference path='../../../collections/models.ts'/>` at the top of a TypeScript file. The code within the file would look something like this:
Then, within WebStorm, go to Preferences -> File Watchers -> "+" symbol and add TypeScript.
Models.Posts.findOne(Session.get('currentPostId'));
For organizational purposes, any additional code related to each Collection can be placed in a separate file per each collection. Alternatively, you could wrap each collection in its own module (e.g. PostsModel for posts, CommentsModel for comments).
If you are not using a TypeScript-aware editor, you can transpile the files using the [Meteor Typescript Compiler](https://github.com/orefalo/meteor-typescript-compiler).
##Reference app
Listed below is a simple Meteor reference application created with TypeScript is listed below. It is based on the Microscope reference app in [Discover Meteor](http://www.discovermeteor.com/ "http://www.discovermeteor.com/").
- Sample Site: <http://microscopic-typescript.meteor.com/>
- Code (TypeScript and transpiled JS): <https://github.com/fullflavedave/MicroscopicTypeScript>
## Example/Reference Projects
* [TypeScript demos](https://github.com/orefalo/meteor-typescript-demos)
+54 -37
View File
@@ -16,9 +16,11 @@
//}
//declare var Template: ITemplate;
var Rooms = new Meteor.Collection('rooms');
var Messages = new Meteor.Collection('messages');
var Monkeys = new Meteor.Collection('monkeys');
var Rooms = new Mongo.Collection('rooms');
var Messages = new Mongo.Collection('messages');
var Monkeys = new Mongo.Collection('monkeys');
var x = new Mongo.Collection('x');
var y = new Mongo.Collection('y');
var check = function(str1, str2) {};
/********************************** End setup for tests *********************************/
@@ -89,9 +91,9 @@ Meteor.publish("counts-by-room", function (roomId) {
});
});
var Counts = new Meteor.Collection("counts");
var Counts = new Mongo.Collection("counts");
Deps.autorun(function () {
Tracker.autorun(function () {
Meteor.subscribe("counts-by-room", Session.get("roomId"));
});
@@ -107,7 +109,7 @@ Meteor.subscribe("allplayers");
/**
* Also from Meteor.subscribe section
*/
Deps.autorun(function () {
Tracker.autorun(function () {
Meteor.subscribe("chat", {room: Session.get("current-room")});
Meteor.subscribe("privateMessages");
});
@@ -139,11 +141,11 @@ Meteor.call('foo', 1, 2, function (error, result) {} );
var result = Meteor.call('foo', 1, 2);
/**
* From Collections, Meteor.Collection section
* From Collections, Mongo.Collection section
*/
// DA: I added the "var" keyword in there
var Chatrooms = new Meteor.Collection("chatrooms");
Messages = new Meteor.Collection("messages");
var Chatrooms = new Mongo.Collection("chatrooms");
Messages = new Mongo.Collection("messages");
var myMessages = Messages.find({userId: Session.get('myUserId')}).fetch();
@@ -151,7 +153,7 @@ Messages.insert({text: "Hello, world!"});
Messages.update(myMessages[0]._id, {$set: {important: true}});
var Posts = new Meteor.Collection("posts");
var Posts = new Mongo.Collection("posts");
Posts.insert({title: "Hello world", body: "First post"});
// Couldn't find assert() in the meteor docs
@@ -161,7 +163,7 @@ Posts.insert({title: "Hello world", body: "First post"});
* Todo: couldn't figure out how to make this next line work with Typescript
* since there is already a Collection constructor with a different signature
*
var Scratchpad = new Meteor.Collection;
var Scratchpad = new Mongo.Collection;
for (var i = 0; i < 10; i++)
Scratchpad.insert({number: i * 2});
assert(Scratchpad.find({number: {$lt: 9}}).count() === 5);
@@ -180,7 +182,7 @@ Animal.prototype = {
// Define a Collection that uses Animal as its document
var Animals = new Meteor.Collection("Animals", {
var Animals = new Mongo.Collection("Animals", {
transform: function (doc) { return new Animal(doc); }
});
@@ -192,8 +194,8 @@ Animals.findOne({name: "raptor"}).makeNoise(); // prints "roar"
* From Collections, Collection.insert section
*/
// DA: I added the variable declaration statements to make this work
var Lists = new Meteor.Collection('Lists');
var Items = new Meteor.Collection('Lists');
var Lists = new Mongo.Collection('Lists');
var Items = new Mongo.Collection('Lists');
var groceriesId = Lists.insert({name: "Groceries"});
Items.insert({list: groceriesId, name: "Watercress"});
@@ -202,7 +204,7 @@ Items.insert({list: groceriesId, name: "Persimmons"});
/**
* From Collections, collection.update section
*/
var Players = new Meteor.Collection('Players');
var Players = new Mongo.Collection('Players');
Template['adminDashboard'].events({
'click .givePoints': function () {
@@ -231,7 +233,7 @@ Template['chat'].events({
});
// DA: I added this next line
var Logs = new Meteor.Collection('logs');
var Logs = new Mongo.Collection('logs');
Meteor.startup(function () {
if (Meteor.isServer) {
@@ -243,7 +245,7 @@ Meteor.startup(function () {
/***
* From Collections, collection.allow section
*/
Posts = new Meteor.Collection("posts");
Posts = new Mongo.Collection("posts");
Posts.allow({
insert: function (userId, doc) {
@@ -287,7 +289,7 @@ topPosts.forEach(function (post) {
* From Collections, cursor.observeChanges section
*/
// DA: I added this line to make it work
var Users = new Meteor.Collection('users');
var Users = new Mongo.Collection('users');
var count1 = 0;
var query = Users.find({admin: true, onlineNow: true});
@@ -308,11 +310,11 @@ setTimeout(function () {handle.stop();}, 5000);
/**
* From Sessions, Session.set section
*/
Deps.autorun(function () {
Tracker.autorun(function () {
Meteor.subscribe("chat-history", {room: Session.get("currentRoomId")});
});
// Causes the function passed to Deps.autorun to be re-run, so
// Causes the function passed to Tracker.autorun to be re-run, so
// that the chat-history subscription is moved to the room "home".
Session.set("currentRoomId", "home");
@@ -419,7 +421,7 @@ Template['adminDashboard'].helpers({
/**
* From Match section
*/
var Chats = new Meteor.Collection('chats');
var Chats = new Mongo.Collection('chats');
Meteor.publish("chats-in-room", function (roomId) {
// Make sure roomId is a string, not an arbitrary mongo selector object.
@@ -451,16 +453,16 @@ check({ name: undefined }, pat) // Throws an exception
check(undefined, Match.Optional('test')); // OK
/**
* From Deps, Deps.autorun section
* From Deps, Tracker.autorun section
*/
Deps.autorun(function () {
Tracker.autorun(function () {
var oldest = Monkeys.findOne('age = 20');
if (oldest)
Session.set("oldest", oldest.name);
});
Deps.autorun(function (c) {
Tracker.autorun(function (c) {
if (! Session.equals("shouldAlert", true))
return;
@@ -471,29 +473,29 @@ Deps.autorun(function (c) {
/**
* From Deps, Deps.Computation
*/
if (Deps.active) {
Deps.onInvalidate(function () {
Monkeys.destroy();
Rooms.finalize();
});
if (Tracker.active) {
Tracker.onInvalidate(function () {
x.destroy();
y.finalize();
});
}
/**
* From Deps, Deps.Dependency
* From Tracker, Tracker.Dependency
*/
var weather = "sunny";
var weatherDep = new Deps.Dependency;
var weatherDep = new Tracker.Dependency;
var getWeather = function () {
weatherDep.depend()
return weather;
weatherDep.depend();
return weather;
};
var setWeather = function (w) {
weather = w;
// (could add logic here to only call changed()
// if the new value is different from the old)
weatherDep.changed();
weather = w;
// (could add logic here to only call changed()
// if the new value is different from the old)
weatherDep.changed();
};
/**
@@ -544,3 +546,18 @@ Meteor.call('sendEmail',
'Hello from Meteor!',
'This is a test of Email.send.');
var testTemplate = new Blaze.Template();
var testView = new Blaze.View();
declare var el: HTMLElement;
Blaze.render(testTemplate, el);
Blaze.renderWithData(testTemplate, {testData: 123}, el);
Blaze.remove(testView);
Blaze.getData(el);
Blaze.getData(testView);
Blaze.toHTML(testTemplate);
Blaze.toHTML(testView);
Blaze.toHTMLWithData(testTemplate, {test: 1});
Blaze.toHTMLWithData(testTemplate, function() {});
Blaze.toHTMLWithData(testView, {test: 1});
Blaze.toHTMLWithData(testView, function() {});
+167 -73
View File
@@ -50,10 +50,6 @@ declare module Meteor {
ready(): boolean;
}
interface CollectionFieldSpecifier {
[id: string]: Number;
}
interface TemplateBase {
[templateName: string]: Meteor.Template;
}
@@ -62,19 +58,6 @@ declare module Meteor {
interface DataContext extends Object {}
enum CollectionIdGenerationEnum {
STRING,
MONGO
}
interface CollectionOptions {
connection: Object;
idGeneration: Meteor.CollectionIdGenerationEnum;
transform?: (document)=>any;
}
function Collection<T>(name:string, options?:Meteor.CollectionOptions) : void;
interface Tinytest {
add(name:string, func:Function);
addAsync(name:string, func:Function);
@@ -145,9 +128,36 @@ declare module Meteor {
}
}
declare module Deps {
declare module Mongo {
interface CollectionFieldSpecifier {
[id: string]: Number;
}
enum CollectionIdGenerationEnum {
STRING,
MONGO
}
// interface CollectionOptions {
// connection: Object;
// idGeneration: Mongo.CollectionIdGenerationEnum;
// transform?: (document)=>any;
// }
//
// function Collection<T>(name:string, options?: Mongo.CollectionOptions) : void;
}
declare module Tracker {
function Computation(): void;
interface Computation {
}
function Dependency(): void;
interface Dependency {
changed(): void;
depend(fromComputation: Tracker.Computation): boolean;
hasDependents(): boolean;
}
}
declare module Package {
@@ -262,14 +272,40 @@ declare module Random {
function choice(str:string):string; // @param str, @return a random char in str
}
declare module Blaze {
interface View {
name: string;
parentView: Blaze.View;
isCreated: boolean;
isRendered: boolean;
isDestroyed: boolean;
renderCount: number;
autorun(runFunc: Function): void;
onViewCreated(func: Function): void;
onViewReady(func: Function): void;
onViewDestroyed(func: Function): void;
firstNode(): Node;
lastNode(): Node;
template: Blaze.Template;
templateInstance(): any;
}
interface Template {
viewName: string;
renderFunction: Function;
constructView(): Blaze.View;
}
}
/**
* These modules and interfaces are automatically generated from the Meteor api.js file
*/
declare module Meteor {
var isClient: boolean;
var isServer: boolean;
var isCordova: boolean;
function startup(func: Function): void;
function absoluteUrl(path?, options?: {
function wrapAsync(func: Function, context?: Object): any;
function absoluteUrl(path?: string, options?: {
secure?: Boolean;
replaceLocalhost?: Boolean;
rootUrl?: string;
@@ -289,14 +325,9 @@ declare module Meteor {
function reconnect(): void;
function disconnect(): void;
function onConnection(callback: Function): void;
function Collection(name: string, options?: {
connection?: Object;
idGeneration?: string;
transform?: Function;
}): void;
function user(): Meteor.User;
function userId(): string;
var users: Meteor.Collection<User>;
var users: Mongo.Collection<User>;
function loggingIn(): boolean;
function logout(callback?: Function): void;
function logoutOtherClients(callback?: Function): void;
@@ -306,11 +337,12 @@ declare module Meteor {
requestOfflineToken?: Boolean;
forceApprovalPrompt?: Boolean;
userEmail?: string;
loginStyle?: string;
}, callback?: Function): void;
function setTimeout(func: Function, delay: Number): number;
function setInterval(func: Function, delay: Number): number;
function clearTimeout(id: Number): void;
function clearInterval(id: Number): void;
function setTimeout(func: Function, delay: number): number;
function setInterval(func: Function, delay: number): number;
function clearTimeout(id: number): void;
function clearInterval(id: number): void;
function EnvironmentVariable(): void;
function get(): string;
function withValue(value: any, func: Function): void;
@@ -329,9 +361,9 @@ declare module Meteor {
equals(a: Meteor.EJSONObject, b: Meteor.EJSONObject, options?: {
keyOrderSensitive?: Boolean;
}): boolean;
clone<T>(v:T): T;
newBinary(size: Number): any;
isBinary(): boolean;
clone<T>(v:T): T; /** TODO: add return value **/
newBinary(size: number): any;
isBinary(x): boolean;
addType(name: string, factory: Function): void;
}
}
@@ -340,24 +372,33 @@ declare module DDP {
function connect(url: string): DDP.DDPStatic;
}
declare module Meteor {
declare module Mongo {
function Collection<T>(name: string, options?: {
connection?: Object;
idGeneration?: Mongo.CollectionIdGenerationEnum;
transform?: (document)=>any;
}): void;
function ObjectID(hexString: string): void;
}
declare module Mongo {
interface Collection<T> {
find(selector?: any, options?: {
sort?: any;
skip?: Number;
limit?: Number;
fields?: Meteor.CollectionFieldSpecifier;
skip?: number;
limit?: number;
fields?: Mongo.CollectionFieldSpecifier;
reactive?: Boolean;
transform?: Function;
});
transform?: (document)=>any;
}): Mongo.Cursor<T>;
findOne(selector?: any, options?: {
sort?: any;
skip?: Number;
fields?: Meteor.CollectionFieldSpecifier;
skip?: number;
fields?: Mongo.CollectionFieldSpecifier;
reactive?: Boolean;
transform?: Function;
});
insert(doc: Object, callback?: Function);
transform?: (document)=>any;
}): Meteor.EJSONObject;
insert(doc: Object, callback?: Function): string;
update(selector: any, modifier: any, options?: {
multi?: Boolean;
upsert?: Boolean;
@@ -368,16 +409,15 @@ declare module Meteor {
remove(selector: any, callback?: Function): void;
allow(options: Meteor.AllowDenyOptions): boolean;
deny(options: Meteor.AllowDenyOptions): boolean;
ObjectID(hexString: string): Object;
}
}
declare module Meteor {
declare module Mongo {
interface Cursor<T> {
count(): number;
fetch(): Array<T>;
forEach(callback: Function, thisArg?): void;
map(callback: Function, thisArg?): void;
fetch(): any[];
forEach(callback: Function, thisArg?: any): void;
map(callback: Function, thisArg?: any): void;
observe(callbacks: Object): Meteor.LiveQueryHandle;
observeChanges(callbacks: Object): Meteor.LiveQueryHandle;
}
@@ -387,17 +427,17 @@ declare module Random {
function id(): string;
}
declare module Deps {
function autorun(runFunc: Function): Deps.Computation;
declare module Tracker {
function autorun(runFunc: Function): Tracker.Computation;
function flush(): void;
function nonreactive(func: Function): void;
var active: boolean;
var currentComputation: Deps.Computation;
var currentComputation: Tracker.Computation;
function onInvalidate(callback: Function): void;
function afterFlush(callback: Function): void;
}
declare module Deps {
declare module Tracker {
interface Computation {
stop(): void;
invalidate(): void;
@@ -408,10 +448,10 @@ declare module Deps {
}
}
declare module Deps {
declare module Tracker {
interface Dependency {
changed(): void;
depend(fromComputation?): boolean;
depend(fromComputation?: Tracker.Computation): boolean;
hasDependents(): boolean;
}
}
@@ -422,7 +462,7 @@ declare module Meteor {
sendVerificationEmail?: Boolean;
forbidClientAccountCreation?: Boolean;
restrictCreationByEmailDomain?: any; // string or Function
loginExpirationInDays?: Number;
loginExpirationInDays?: number;
oauthSecretKey?: string;
}): void;
ui: {
@@ -431,13 +471,13 @@ declare module Meteor {
requestOfflineToken?: Object;
forceApprovalPrompt?: Boolean;
passwordSignupFields?: string;
});
}); /** TODO: add return value **/
}
validateNewUser(func: Function): void;
onCreateUser(func: Function): void;
validateLoginAttempt(func: Function);
onLogin(func: Function);
onLoginFailure(func: Function);
validateLoginAttempt(func: Function); /** TODO: add return value **/
onLogin(func: Function); /** TODO: add return value **/
onLoginFailure(func: Function); /** TODO: add return value **/
createUser(options: {
username?: string;
email?: string;
@@ -451,9 +491,9 @@ declare module Meteor {
resetPassword(token: string, newPassword: string, callback?: Function): void;
setPassword(userId: string, newPassword: string): void;
verifyEmail(token: string, callback?: Function): void;
sendResetPasswordEmail(userId: string, email?): void;
sendEnrollmentEmail(userId: string, email?): void;
sendVerificationEmail(userId: string, email?): void;
sendResetPasswordEmail(userId: string, email?: string): void;
sendEnrollmentEmail(userId: string, email?: string): void;
sendVerificationEmail(userId: string, email?: string): void;
emailTemplates: Meteor.EmailTemplates;
}
}
@@ -481,7 +521,7 @@ declare module HTTP {
params?: Object;
auth?: string;
headers?: Object;
timeout?: Number;
timeout?: number;
followRedirects?: Boolean;
}, asyncCallback?): HTTP.HTTPResponse;
function get(url, options?: {
@@ -501,18 +541,44 @@ declare module Meteor {
destroyed: Function;
events(eventMap: {[id:string]: Function}): void;
helpers(helpers: Object): void;
findAll(selector: string); /** TODO: add return value **/
$(selector: string); /** TODO: add return value **/
find(selector?: string); /** TODO: add return value **/
firstNode; /** TODO: add return value **/
lastNode; /** TODO: add return value **/
data; /** TODO: add return value **/
autorun(runFunc: Function); /** TODO: add return value **/
view; /** TODO: add return value **/
registerHelper(name: string, func: Function); /** TODO: add return value **/
body; /** TODO: add return value **/
currentData(); /** TODO: add return value **/
instance(); /** TODO: add return value **/
parentData(numLevels: number); /** TODO: add return value **/
}
}
declare module Blaze {
function render(templateOrView: any, parentNode: Node, nextNode?: Node, parentView?: Blaze.View): Blaze.View;
function renderWithData(templateOrView: any, data: any, parentNode: Node, nextNode?: Node, parentView?: Blaze.View): Blaze.View;
function remove(renderedView: Blaze.View): void;
function With(data: any, contentFunc: Function); /** TODO: add return value **/
function If(conditionFunc: Function, contentFunc: Function, elseFunc?: Function); /** TODO: add return value **/
function Unless(conditionFunc: Function, contentFunc: Function, elseFunc?: Function); /** TODO: add return value **/
function Each(argFunc: Function, contentFunc: Function, elseFunc?: Function); /** TODO: add return value **/
function getData(elementOrView?: any); /** TODO: add return value **/
var currentView; /** TODO: add return value **/
function getView(element?: HTMLElement); /** TODO: add return value **/
function toHTML(templateOrView: any): string;
function toHTMLWithData(templateOrView: any, data: any): string;
function View(name?: string, renderFunction?: Function): void;
function Template(viewName?: string, renderFunction?: Function): void;
function isTemplate(value: any): boolean;
}
declare module Meteor {
interface UI {
registerHelper(name: string, func: Function): void;
body: Meteor.Template;
render(template): Meteor.RenderedTemplate;
renderWithData(template, data: Object): Meteor.RenderedTemplate;
insert(renderedTemplate: RenderedTemplate, parentNode, nextNode?): void;
remove(renderedTemplate: RenderedTemplate): void;
getElementData(el: HTMLElement): Meteor.DataContext;
interface ReactiveVar {
get(); /** TODO: add return value **/
set(newValue: any); /** TODO: add return value **/
}
}
@@ -531,8 +597,36 @@ declare module Email {
}
declare module Assets {
function getText(assetPath: string, asyncCallback?): string;
function getBinary(assetPath: string, asyncCallback?): Meteor.EJSON;
function getText(assetPath: string, asyncCallback?: Function): string;
function getBinary(assetPath: string, asyncCallback?: Function): Meteor.EJSON;
}
declare module Meteor {
interface Package {
describe(options: {
summary?: string;
version?: string;
name?: string;
git?: string;
}); /** TODO: add return value **/
onUse(f: Function); /** TODO: add return value **/
onTest(f: Function); /** TODO: add return value **/
describe(options: {
}); /** TODO: add return value **/
}
}
declare module Meteor {
interface Api {
use(packageNameAndVersion?: string, architecture?: string, options?: {
weak?: Boolean;
unordered?: Boolean;
}); /** TODO: add return value **/
versionsFrom(meteorversion: string); /** TODO: add return value **/
imply(packagespecOrpackagespecs: any); /** TODO: add return value **/
export(exportedObject: string, architecture?: string); /** TODO: add return value **/
addFiles(filenameOrfilenames: any); /** TODO: add return value **/
}
}
declare var Template: Meteor.TemplateBase;