Typescript and Webstorm --> Typing problem in default Hello App


#1

Hi,

I’m using Webstorm 10 on OSx.
I just started with Meteor and Typescript. I created a default meteor project (hello app) via commandline.
I wanted to see how the typing worked with meteor and changed the hello.js to hello.ts.

After installing the typescript-libs and the typescript-compiler via commandline and using this reference path:
´/// <reference path=".meteor/local/build/programs/server/assets/packages/meteortypescript_typescript-libs/definitions/all-definitions.d.ts" />
It recognized the meteor objects and functions.

What it did not recognize is the template name defined in the hello.html (i assume).
When compiling the app this error is shown:

While building the application:
/Users/sebastiankopf/Entwicklung/WebstormProjects/meteortest6/hello.ts:8:2:
error TS2339: Property 'hello' does not exist on type 'TemplateStatic'.

This is the code for the hello.html:

<head>
<title>hello</title>
</head>

<body>
<h1>Welcome to Meteor!</h1>

{{> hello}}
</body>

<template name="hello">
<button>Click Me</button>
<p>You've pressed the button {{counter}} times.</p>
</template>

And this is the code in the hello.ts:

/// <reference path=".meteor/local/build/programs/server/assets/packages/meteortypescript_typescript-libs/definitions/all-definitions.d.ts" />

if (Meteor.isClient) {
// counter starts at 0
Session.setDefault('counter', 0);

Template.hello.helpers({
counter: function () {
  return Session.get('counter');
}
});

Template.hello.events({
'click button': function () {
  // increment the counter when button is clicked
  Session.set('counter', Session.get('counter') + 1);
}
});
}

if (Meteor.isServer) {
 Meteor.startup(function () {
// code to run on server at startup
});
}

So is there any configuration I missed?


#2

You should write Template['hello'].helpers({