Where is the TypeScript love?

It’s a work in progress.

Back in June there was an announcement about a better way to acquire typings though npm. It can be found here:
https://blogs.msdn.microsoft.com/typescript/2016/06/15/the-future-of-declaration-files/

Some of the progress has been made already. Right now this tool https://github.com/Microsoft/types-publisher automatically publish all the type definitions from the dt repository https://github.com/DefinitelyTyped/DefinitelyTyped to npm https://www.npmjs.com/~types/.

Also, there was some talk about making typescript look for type definitions inside the npm packages before looking in a separate typings directory. It would allow package authors to include typings that fit each package version, so you don’t have to install them manually.

My test app is running fine however I get errors:

After I run

meteor add react-meteor-data

and call

 import { createContainer } from 'meteor/react-meteor-data';

I get

"Cannot find module 'meteor/react-meteor-data'."

The same warning appears when I call imports from the root folder, i.e.:

import { Bookings } from '/external/collections/bookings.js'

Any ideas?

I’m having a look at it now.

Is there any larger example app like the “todo-react” one (but with React & TypeScript)?

So, for the first error you might need typings. Try to run console.log( createContainer ) after the import statement to check if it is loaded even though the error appear. I my case it worked fine.

For the import { Bookings }, could you double check that allowJs is true in tsconfig.json? It will give you that exact error if it is false, and it works in my case when I import from the root folder like that.

I have a few apps of my own, but they are not written as tutorials. It shouldn’t take long to write the react-todo using typescript though.

First of all: Thank you very much for your support @birk.

So, for the first error you might need typings. Try to run console.log( createContainer ) after the import statement to check if it is loaded even though the error appear. I my case it worked fine.

How do I get typings for meteor packages like meteor-react-data? “typings search” did not work for me.

For the import { Bookings }, could you double check that allowJs is true in tsconfig.json? It will give you that exact error if it is false, and it works in my case when I import from the root folder like that.

Jupp, it is enabled. If I call the relative path it works fine:

import { Bookings } from '../../../external/collections/bookings.js'

The strange thing here is TypeScript seems to accept the non relational “external/” but then Meteor throws an error. If I use “/external/” the Meteor app works fine but TS throws an error.

I have a few apps of my own, but they are not written as tutorials. It shouldn’t take long to write the react-todo using typescript though.

Also a public one? I would love to see just how things are done (e.g. SimpleSchema, Admin Page, …).

Thanks again.

You could install the typings through the cli as you mention, but they unfortunately doesn’t exist for that package.

It sounds weird with the “/external/” issue. I have take a look at it if you make a small repro, but it’s difficult to do without as it works for me.

I’m not aware of a large public demo repo right now, but I’m sure they will come at some point.

Hm. Seems that right now I have to live with many warnings for unknown modules in CLI and IDE. :frowning:

Me too. It’s a pain point, and the only way to get out of it is to define “empty” type definitions with a lot of “any” types.

I guess it takes too much time to setup.
I tried angular2 + meteor + typescript.
The setup process is not so easy.

Dang. Is there maybe a flag for that?

In the IDE I can use:

//noinspection TypeScriptCheckImport

@genzai, I have made a sample doing exactly that, so it’s now easy to get started with Angular:

@obiwahn, your question about how to acquire types are explained here:

1 Like