Skip to content

Commit 2ddf38b

Browse files
authored
Merge pull request #1 from jumperchen/keikai
"Get latest changes from dart-archive/ts2dart master #1"
2 parents c43031f + 65073d2 commit 2ddf38b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+5300
-733
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
phutil_register_library('npm-test', __FILE__);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
/**
4+
* This file is automatically generated. Use 'arc liberate' to rebuild it.
5+
*
6+
* @generated
7+
* @phutil-library-version 2
8+
*/
9+
phutil_register_library_map(array(
10+
'__library_version__' => 2,
11+
'class' => array(
12+
'NpmUnitTestEngine' => 'src/NpmUnitTestEngine.php',
13+
),
14+
'function' => array(),
15+
'xmap' => array(
16+
'NpmUnitTestEngine' => 'ArcanistUnitTestEngine',
17+
),
18+
));
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
class NpmUnitTestEngine extends ArcanistUnitTestEngine {
3+
public function run() {
4+
$retval = 0;
5+
system('npm test', $retval);
6+
$result = new ArcanistUnitTestResult();
7+
$result->setName('npm test');
8+
if ($retval == 0) {
9+
$result->setResult(ArcanistUnitTestResult::RESULT_PASS);
10+
} else {
11+
$result->setResult(ArcanistUnitTestResult::RESULT_FAIL);
12+
}
13+
return array($result);
14+
}
15+
16+
public function shouldEchoTestResults() {
17+
return false;
18+
}
19+
}
20+
?>

.arcconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"base": "git:origin/master",
3+
"phabricator.uri" : "https://reviews.angular.io/",
4+
"load": [
5+
".arc/npm-test"
6+
],
7+
"unit.engine": "NpmUnitTestEngine"
8+
}

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Compiled JS
2-
build
32

43
# Logs
54
logs
@@ -9,6 +8,7 @@ logs
98
pids
109
*.pid
1110
*.seed
11+
.phutil_module_cache
1212

1313
# Type definitions installed with tsd
1414
typings
@@ -30,3 +30,7 @@ node_modules
3030

3131
# Users Environment Variables
3232
.lock-wscript
33+
34+
# IDEs
35+
.idea/
36+
/ts2dart.iml

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# TypeScript to Dart transpiler [![Build Status](https://travis-ci.org/angular/ts2dart.svg?branch=master)](https://travis-ci.org/angular/ts2dart)
22

3+
ts2dart is a TypeScript to Dart transpiler. It's mainly used to translate Angular 2 from TypeScript
4+
to Dart for its Dart user base.
35

4-
ts2dart is a TypeScript to Dart transpiler. It's in its very early days and under heavy development,
5-
not ready for production use.
6+
## Usage
7+
8+
- To install as Command Line Tool execute: `npm i -g ts2dart`
9+
- Once installed you could run it doing: `ts2dart inputFile.ts`
610

711
## Installation
812

@@ -15,3 +19,15 @@ not ready for production use.
1519
- `gulp test.e2e` executes the e2e tests,
1620
- `gulp test.check-format` checks the source code formatting using `clang-format`,
1721
- `gulp test` runs unit tests, e2e tests and checks the source code formatting.
22+
23+
## Phabricator Reviews
24+
25+
You can send pull requests via Github, or by creating a Phabricator diff on
26+
https://reviews.angular.io. Both are fine, though Phabricator has a nicer code review UI.
27+
28+
To create a Phabricator diff:
29+
30+
- create an account on https://reviews.angular.io
31+
- install [Arcanist](https://secure.phabricator.com/book/phabricator/article/arcanist/)
32+
- run `arc diff` to upload a diff (= pull request). This will also run all tests.
33+
- get it reviewed by entering a "Reviewer", e.g. "mprobst", "alexeagle", "viks", ...

build/definitions/base.d.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import * as ts from 'typescript';
2+
import { Transpiler } from './main';
3+
export declare type ClassLike = ts.ClassDeclaration | ts.InterfaceDeclaration;
4+
export declare function ident(n: ts.Node): string;
5+
export declare class TranspilerBase {
6+
private transpiler;
7+
private idCounter;
8+
constructor(transpiler: Transpiler);
9+
visit(n: ts.Node): void;
10+
emit(s: string): void;
11+
emitBefore(s: string, search: string): void;
12+
emitNoSpace(s: string): void;
13+
reportError(n: ts.Node, message: string): void;
14+
visitNode(n: ts.Node): boolean;
15+
visitEach(nodes: ts.Node[]): void;
16+
visitEachIfPresent(nodes?: ts.Node[]): void;
17+
visitList(nodes: ts.Node[], separator?: string): void;
18+
uniqueId(name: string): string;
19+
assert(c: ts.Node, condition: boolean, reason: string): void;
20+
getAncestor(n: ts.Node, kind: ts.SyntaxKind): ts.Node;
21+
hasAncestor(n: ts.Node, kind: ts.SyntaxKind): boolean;
22+
hasAnnotation(decorators: ts.NodeArray<ts.Decorator>, name: string): boolean;
23+
hasFlag(n: {
24+
flags: number;
25+
}, flag: ts.NodeFlags): boolean;
26+
maybeDestructureIndexType(node: ts.TypeLiteralNode): [ts.TypeNode, ts.TypeNode];
27+
getRelativeFileName(fileName: string): string;
28+
maybeVisitTypeArguments(n: {
29+
typeArguments?: ts.NodeArray<ts.TypeNode>;
30+
}): void;
31+
}

build/definitions/call.d.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import ts = require('typescript');
2+
import base = require('./base');
3+
import ts2dart = require('./main');
4+
import { FacadeConverter } from './facade_converter';
5+
export default class CallTranspiler extends base.TranspilerBase {
6+
private fc;
7+
constructor(tr: ts2dart.Transpiler, fc: FacadeConverter);
8+
visitNode(node: ts.Node): boolean;
9+
private visitCall(c);
10+
private handleNamedParamsCall(c);
11+
/**
12+
* Handles constructor initializer lists and bodies.
13+
*
14+
* <p>Dart's super() ctor calls have to be moved to the constructors initializer list, and `const`
15+
* constructors must be completely empty, only assigning into fields through the initializer list.
16+
* The code below finds super() calls and handles const constructors, marked with the special
17+
* `@CONST` annotation on the class.
18+
*
19+
* <p>Not emitting super() calls when traversing the ctor body is handled by maybeHandleSuperCall
20+
* below.
21+
*/
22+
private visitConstructorBody(ctor);
23+
/**
24+
* Checks whether `callExpr` is a super() call that should be ignored because it was already
25+
* handled by `maybeEmitSuperInitializer` above.
26+
*/
27+
private maybeHandleSuperCall(callExpr);
28+
}

build/definitions/declaration.d.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import * as ts from 'typescript';
2+
import * as base from './base';
3+
import { FacadeConverter } from './facade_converter';
4+
import { Transpiler } from './main';
5+
export default class DeclarationTranspiler extends base.TranspilerBase {
6+
private fc;
7+
private enforceUnderscoreConventions;
8+
constructor(tr: Transpiler, fc: FacadeConverter, enforceUnderscoreConventions: boolean);
9+
visitNode(node: ts.Node): boolean;
10+
private visitVariableDeclarationType(varDecl);
11+
private visitFunctionLike(fn, accessor?);
12+
private visitParameters(parameters);
13+
/**
14+
* Visit a property declaration.
15+
* In the special case of property parameters in a constructor, we also allow a parameter to be
16+
* emitted as a property.
17+
*/
18+
private visitProperty(decl, isParameter?);
19+
private visitClassLike(keyword, decl);
20+
private visitDecorators(decorators);
21+
private visitDeclarationMetadata(decl);
22+
private visitNamedParameter(paramDecl);
23+
private getInitializers(paramDecl);
24+
/**
25+
* Handles a function typedef-like interface, i.e. an interface that only declares a single
26+
* call signature, by translating to a Dart `typedef`.
27+
*/
28+
private visitFunctionTypedefInterface(name, signature, typeParameters);
29+
}

build/definitions/expression.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import * as ts from 'typescript';
2+
import * as base from './base';
3+
import { FacadeConverter } from './facade_converter';
4+
import { Transpiler } from './main';
5+
export default class ExpressionTranspiler extends base.TranspilerBase {
6+
private fc;
7+
constructor(tr: Transpiler, fc: FacadeConverter);
8+
visitNode(node: ts.Node): boolean;
9+
visitAndWrapAsInt(n: ts.Expression): void;
10+
}

0 commit comments

Comments
 (0)