├── .gitignore
├── LICENSE
├── README.md
├── package.js
├── plugin.js
└── tests
├── runtime-react-tests.tsx
└── runtime-tests.ts
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 | .npm
3 | demo
4 | .meteor/local
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Alex Borodach
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Deprecated! Use https://atmospherejs.com/adornis/typescript
2 | ## TypeScript Compiler for Meteor
3 |
4 | TypeScript files are compiled into ES5 and CommonJS modules by default.
5 |
6 | > Based on TypeScript@2.8.3
7 |
8 | Default compiler options as JSON:
9 | ````json
10 | {
11 | "module": "commonjs",
12 | "target": "es5",
13 | "moduleResolution": "node",
14 | "experimentalDecorators": true,
15 | "emitDecoratorMetadata": true,
16 | "sourceMap": true
17 | }
18 | ````
19 | ## ES6
20 |
21 | It's possible to use ES6 on the server with Meteor >= 1.4.
22 |
23 | If you want to compile into ES6 on the server, put a `tsconfig.json` into the server folder:
24 | ```json
25 | {
26 | "compilerOptions": {
27 | "target": "ES6"
28 | }
29 | }
30 | ```
31 |
32 | ## Path mappings
33 |
34 | TypeScript paths mapping is supported since `0.6.0`, though,
35 | with some limitations. It works only for local files and for `module: commonjs`.
36 |
37 | You can now use paths like `imports/client/foo` instead of Meteor rooted
38 | paths like `/imports/client/foo` if you add to the `config.json` as follows:
39 | ```json
40 | "baseUrl": ".",
41 | "paths": {
42 | "*": ["*"]
43 | }
44 | ```
45 |
46 | ## Typings
47 |
48 | Install Meteor typings by `npm i @types/meteor` and you are ready to go.
49 |
50 | ### Custom Typings
51 |
52 | Typings files are processed in the same way as regular ts-files.
53 | If you place a declaration file into server folder it will be used only for the server code only.
54 |
55 | Note that any change to a global declaration file will cause diagnostics re-evaluation.
56 | Hence, if you change some custom declaration file often, makes sence to reference it in some main ts-file
57 | and exclude in the config, i.e.:
58 | ```ts
59 | ///
60 | ```
61 | ```json
62 | {
63 | "exclude": ["typings/foo.d.ts"]
64 | }
65 | ```
66 |
67 | ## Example
68 |
69 | As an example, check out a simple TODO app built with Angular2 and TypeScript,
70 | https://github.com/Urigo/angular-meteor/tree/master/examples/todos-meteor-1.3
71 |
72 | ## Package Structure
73 |
74 | This package uses (directly or indirectly) three other packages, which are worth to mention:
75 |
76 | [typescript-compiler](https://github.com/barbatus/typescript-compiler) - exports a Meteor TypeScript compiler that implements Meteor compiler API. TypeScript compiler in its turn uses [meteor-typescript](https://github.com/barbatus/meteor-typescript) package’s API
77 | to compile TypeScript source code incrementally on file changes.
78 |
79 | [meteor-typescript](https://github.com/barbatus/meteor-typescript) - an NPM package that exports an incremental TypeScript build class.
80 | 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.
81 |
82 | [typescript-runtime](https://github.com/barbatus/typescript-runtime) - currently contains TypeScript helpers,
83 | 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.
84 |
85 | ## Credits
86 |
87 | Thanks @urigo (Uri) for his support and resources to continue
88 | development of this project.
89 |
90 | ## License
91 | MIT
92 |
--------------------------------------------------------------------------------
/package.js:
--------------------------------------------------------------------------------
1 | Package.describe({
2 | name: 'barbatus:typescript',
3 | version: '0.7.0',
4 | summary: 'TypeScript for Meteor',
5 | git: 'https://github.com/barbatus/typescript',
6 | documentation: 'README.md'
7 | });
8 |
9 | Package.registerBuildPlugin({
10 | name: 'typescript',
11 | use: ['barbatus:typescript-compiler'],
12 | sources: ['plugin.js']
13 | });
14 |
15 | Package.onUse(function(api) {
16 | api.versionsFrom('1.4.1');
17 |
18 | api.use('isobuild:compiler-plugin@1.0.0');
19 | api.use('barbatus:typescript-compiler@0.10.0');
20 |
21 | api.imply('modules@0.11.6');
22 |
23 | api.imply('barbatus:typescript-runtime@1.1.0');
24 | });
25 |
26 | Package.onTest(function(api) {
27 | api.use('tinytest@1.0.12');
28 | api.use('barbatus:typescript');
29 |
30 | api.addFiles('tests/runtime-tests.ts', 'client');
31 | api.addFiles('tests/runtime-react-tests.tsx', 'client');
32 | });
33 |
--------------------------------------------------------------------------------
/plugin.js:
--------------------------------------------------------------------------------
1 | Plugin.registerCompiler({
2 | extensions: ['ts', 'tsx'],
3 | filenames: ['tsconfig.json']
4 | }, function () {
5 | return new TypeScriptCompiler({
6 | jsx: 'react'
7 | });
8 | });
9 |
--------------------------------------------------------------------------------
/tests/runtime-react-tests.tsx:
--------------------------------------------------------------------------------
1 | var React = {
2 | createElement(elName, props) {
3 | return { elName, props };
4 | }
5 | }
6 |
7 | Tinytest.add('typescript - runtime - react', (test) => {
8 | {
9 | let props = {
10 | style: { display: 'block' }
11 | };
12 | class Component {
13 | render() {
14 | return
;
15 | }
16 | }
17 |
18 | let element = { elName: 'div', props };
19 | test.equal((new Component()).render(), element);
20 | }
21 | });
22 |
--------------------------------------------------------------------------------
/tests/runtime-tests.ts:
--------------------------------------------------------------------------------
1 | Tinytest.addAsync('typescript - runtime - async', (test, onComplete) => {
2 | {
3 | async function service() { return 1; }
4 |
5 | service().then(result => {
6 | test.equal(result, 1);
7 | onComplete();
8 | });
9 | }
10 | });
11 |
12 | Tinytest.add('typescript - runtime - decorators', (test) => {
13 | {
14 | function classDecorator() {
15 | return function(cls) {
16 | cls.prototype.foo = 'foo';
17 | };
18 | }
19 |
20 | @classDecorator()
21 | class Foo {}
22 |
23 | test.equal((new Foo()).foo, 'foo');
24 | }
25 | });
26 |
--------------------------------------------------------------------------------