• This repository has been archived on 19/Feb/2020
  • Stars
    star
    99
  • Rank 343,315 (Top 7 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 9 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Add TypeScript to Meteor

Deprecated! Use https://atmospherejs.com/adornis/typescript

TypeScript Compiler for Meteor

TypeScript files are compiled into ES5 and CommonJS modules by default.

Based on [email protected]

Default compiler options as JSON:

{
  "module": "commonjs",
  "target": "es5",
  "moduleResolution": "node",
  "experimentalDecorators": true,
  "emitDecoratorMetadata": true,
  "sourceMap": true
}

ES6

It's possible to use ES6 on the server with Meteor >= 1.4.

If you want to compile into ES6 on the server, put a tsconfig.json into the server folder:

{
  "compilerOptions": {
    "target": "ES6"
  }
}

Path mappings

TypeScript paths mapping is supported since 0.6.0, though, with some limitations. It works only for local files and for module: commonjs.

You can now use paths like imports/client/foo instead of Meteor rooted paths like /imports/client/foo if you add to the config.json as follows:

  "baseUrl": ".",
  "paths": {
    "*": ["*"]
  }

Typings

Install Meteor typings by npm i @types/meteor and you are ready to go.

Custom Typings

Typings files are processed in the same way as regular ts-files. If you place a declaration file into server folder it will be used only for the server code only.

Note that any change to a global declaration file will cause diagnostics re-evaluation. Hence, if you change some custom declaration file often, makes sence to reference it in some main ts-file and exclude in the config, i.e.:

 /// <reference path="typings/foo.d.ts" />
{
  "exclude": ["typings/foo.d.ts"]
}

Example

As an example, check out a simple TODO app built with Angular2 and TypeScript, https://github.com/Urigo/angular-meteor/tree/master/examples/todos-meteor-1.3

Package Structure

This package uses (directly or indirectly) three other packages, which are worth to mention:

typescript-compiler - exports a Meteor TypeScript compiler that implements Meteor compiler API. TypeScript compiler in its turn uses meteor-typescript package’s API to compile TypeScript source code incrementally on file changes.

meteor-typescript - an NPM package that exports an incremental TypeScript build class. That class is designed to be used in the series of subsequent compilations of TypeScript source code. In that case, TypeScript Service API, which is used internally, allows to reuse compilation statistics and data between subsequent builds, thus, improving speed of the compilation.

typescript-runtime - currently contains TypeScript helpers, which allow to configure behavior of some parts of the compiled TypeScript code for special use cases. One of the use cases is usage with the old browsers.

Credits

Thanks @urigo (Uri) for his support and resources to continue development of this project.

License

MIT

More Repositories

1

ionic2-meteor

Ionic2 packaged for Meteor
JavaScript
38
star
2

stars-rating

Stars rating control for Meteor
JavaScript
21
star
3

angular2-compiler

Brings AoT compilation to your legs
JavaScript
14
star
4

typescript-compiler

TypeScript Compilers for Meteor
JavaScript
14
star
5

angular2-meteor-universal

Server Side Rendering for Angular2-Meteor
JavaScript
14
star
6

angular2

Angular2 Packaged for Meteor
JavaScript
14
star
7

ng2-meteor-accounts

Meteor Accounts for Angular2
TypeScript
13
star
8

angular2-meteor-polyfills

Polyfills for Angular2-Meteor apps
JavaScript
5
star
9

ng2-pipes

Experiments with Angular 2's Pipes API
TypeScript
5
star
10

ng2-material

Ng2 Material Design packaged for Meteor
TypeScript
4
star
11

discipline2

Activity Trackers App built with React Native
JavaScript
4
star
12

ng2-ssr-demo

TypeScript
4
star
13

meteor-typescript

JavaScript
4
star
14

ng2-meteor-accounts-ui

Meteor Accounts UI packaged for Angular2
JavaScript
4
star
15

meteor-ionic-autocomplete

Ionic autocomplete dropdown directive
JavaScript
3
star
16

angular-wizard

Wraps Angular UI logic into a series of steps (pages/slides) aka a wizard
JavaScript
3
star
17

ng-infinite-scroll

JavaScript
3
star
18

typescript-runtime

TypeScript Runtime Dependencies
JavaScript
2
star
19

ng2-todo-ssr

TypeScript
2
star
20

discipline

Productivity mobile app to track different types of daily activities
JavaScript
2
star
21

revolut

Example app built with TypeScript + MobX + CSS modules
TypeScript
1
star
22

ngc-demos

Angular-Compiler demos
CSS
1
star
23

vssr

TypeScript
1
star
24

ng2-minifier-js

JavaScript
1
star
25

algo

Algorithmic challenges programmed with JS
JavaScript
1
star