You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 13, 2022. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+4-5Lines changed: 4 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
1
# babel-plugin-transform-ng1-jsx
2
2
3
-
A proof of concept of type-checking Angular 1 templates with TypeScript.
3
+
A proof of concept of type-checking Angular 1 templates with TypeScript.
4
4
5
-
The idea is to use [JSX](https://facebook.github.io/jsx/) for the templates, to type-check them with TypeScript, and to convert them into the usual HTML string representation with a Babel plugin.
5
+
The idea is to use [JSX](https://facebook.github.io/jsx/) for the templates, to type-check them with TypeScript, and to convert them into the usual HTML string representation with a Babel plugin.
6
6
7
7
The solution consists of two parts:
8
8
9
-
1. Type definitions for JSX ([`ng1-jsx.d.ts`](ng1-jsx.d.ts))
9
+
1. Type definitions for JSX ([`ng1-jsx.ts`](ng1-jsx.ts))
10
10
2. The Babel plugin
11
11
12
12
Written in JSX, templates become just part of the TypeScript code. Include the type definitions with a `/// <reference path="..." />` comment, and use the [`--jsx preserve`](https://github.com/Microsoft/TypeScript/wiki/JSX) mode (`"jsx": "preserve"` in `tsconfig.json`) for the TypeScript compiler to understand and emit JSX. Finally, use the Babel plugin to compile JSX into HTML strings.
@@ -52,8 +52,6 @@ You can find an example to play with in the `example` folder. Run `npm run build
52
52
53
53
# Issues / TBD
54
54
55
-
* Type-checking component attributes. This one currently is **a big show stopper**. TypeScript _almost_ (but not quite) allows this. See the comments in [`ng1-jsx.d.ts`](ng1-jsx.d.ts).
56
-
57
55
* Non-JS syntax elements in Angular expressions: filters and one-time bindings.
58
56
59
57
The comma operator can help with this: `attr={ '|myFilter', $ctrl.foo }`, `ng-if={ '::', $ctrl.flag }`. This seems to be a good solution for one-time bindings, however the filters can change the type of the resulting value, so it's not type-checkable.
@@ -71,4 +69,5 @@ You can find an example to play with in the `example` folder. Run `npm run build
71
69
*[JSX in TypeScript](https://github.com/Microsoft/TypeScript/wiki/JSX)
*[TypeScript, issue #7004: JSX: a way to make all the properties of value-based elements optional](https://github.com/Microsoft/TypeScript/issues/7004)
74
73
*[Refactoring Angular Apps to Component Style](http://teropa.info/blog/2015/10/18/refactoring-angular-apps-to-components.html)
0 commit comments