mirror of
https://github.com/facebook/react.git
synced 2026-02-26 16:05:00 +00:00
As part of the new class effort it is now possible to define React Components using any type of generic JavaScript class syntax. This includes TypeScript classes. This test ensures that we don't regress that support, and also serves as an example for using React in TypeScript. TypeScript provides a good demo of where we think property initializers are going. We don't have any official *type* support for TypeScript yet. This test trails the ReactES6Class-test file. Some manual tweaking is required when converting tests.
32 lines
812 B
JavaScript
32 lines
812 B
JavaScript
"use strict";
|
|
|
|
var ReactTools = require('../main.js');
|
|
|
|
var coffee = require('coffee-script');
|
|
var ts = require('ts-compiler');
|
|
|
|
module.exports = {
|
|
process: function(src, path) {
|
|
if (path.match(/\.coffee$/)) {
|
|
return coffee.compile(src, {'bare': true});
|
|
}
|
|
if (path.match(/\.ts$/) && !path.match(/\.d\.ts$/)) {
|
|
ts.compile([path], {
|
|
skipWrite: true,
|
|
module: 'commonjs'
|
|
}, function(err, results) {
|
|
if (err) {
|
|
throw err;
|
|
}
|
|
results.forEach(function(file) {
|
|
// This is gross, but jest doesn't provide an asynchronous way to
|
|
// process a module, and ts currently runs syncronously.
|
|
src = file.text;
|
|
});
|
|
});
|
|
return src;
|
|
}
|
|
return ReactTools.transform(src, {harmony: true});
|
|
}
|
|
};
|