Tests for react/ts compat and flow/ts compat.
This commit is contained in:
parent
cc5aeb3b50
commit
f2882d570a
@ -343,10 +343,10 @@ function run(task) {
|
||||
newOpts.presets,
|
||||
optionsDir,
|
||||
).map(function(val) {
|
||||
if (val.length > 2) {
|
||||
if (val.length > 3) {
|
||||
throw new Error(
|
||||
"Unexpected extra options " +
|
||||
JSON.stringify(val.slice(2)) +
|
||||
JSON.stringify(val.slice(3)) +
|
||||
" passed to preset.",
|
||||
);
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
"@babel/core": "7.0.0-beta.47"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.0.0-beta.47"
|
||||
"@babel/core": "7.0.0-beta.47",
|
||||
"@babel/helper-plugin-test-runner": "7.0.0-beta.47"
|
||||
}
|
||||
}
|
||||
|
||||
5
packages/babel-preset-typescript/test/fixtures/flow-compat/js-invalid/input.js
vendored
Normal file
5
packages/babel-preset-typescript/test/fixtures/flow-compat/js-invalid/input.js
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
enum Example {
|
||||
Value
|
||||
}
|
||||
|
||||
foo;
|
||||
8
packages/babel-preset-typescript/test/fixtures/flow-compat/js-invalid/options.json
vendored
Normal file
8
packages/babel-preset-typescript/test/fixtures/flow-compat/js-invalid/options.json
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"presets": [
|
||||
["flow", {}, "before"],
|
||||
"typescript",
|
||||
["flow", {}, "after"]
|
||||
],
|
||||
"throws": "enum is a reserved word (1:0)"
|
||||
}
|
||||
3
packages/babel-preset-typescript/test/fixtures/flow-compat/js-valid/input.js
vendored
Normal file
3
packages/babel-preset-typescript/test/fixtures/flow-compat/js-valid/input.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
type Foo = {||};
|
||||
|
||||
foo;
|
||||
1
packages/babel-preset-typescript/test/fixtures/flow-compat/js-valid/output.js
vendored
Normal file
1
packages/babel-preset-typescript/test/fixtures/flow-compat/js-valid/output.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
foo;
|
||||
7
packages/babel-preset-typescript/test/fixtures/flow-compat/options.json
vendored
Normal file
7
packages/babel-preset-typescript/test/fixtures/flow-compat/options.json
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"presets": [
|
||||
["flow", {}, "before"],
|
||||
"typescript",
|
||||
["flow", {}, "after"]
|
||||
]
|
||||
}
|
||||
3
packages/babel-preset-typescript/test/fixtures/flow-compat/ts-invalid/input.ts
vendored
Normal file
3
packages/babel-preset-typescript/test/fixtures/flow-compat/ts-invalid/input.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
type Foo = {||};
|
||||
|
||||
foo;
|
||||
8
packages/babel-preset-typescript/test/fixtures/flow-compat/ts-invalid/options.json
vendored
Normal file
8
packages/babel-preset-typescript/test/fixtures/flow-compat/ts-invalid/options.json
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"presets": [
|
||||
["flow", {}, "before"],
|
||||
"typescript",
|
||||
["flow", {}, "after"]
|
||||
],
|
||||
"throws": "Unexpected token (1:12)"
|
||||
}
|
||||
5
packages/babel-preset-typescript/test/fixtures/flow-compat/ts-valid/input.ts
vendored
Normal file
5
packages/babel-preset-typescript/test/fixtures/flow-compat/ts-valid/input.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
enum Example {
|
||||
Value
|
||||
}
|
||||
|
||||
foo;
|
||||
7
packages/babel-preset-typescript/test/fixtures/flow-compat/ts-valid/output.js
vendored
Normal file
7
packages/babel-preset-typescript/test/fixtures/flow-compat/ts-valid/output.js
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
var Example;
|
||||
|
||||
(function (Example) {
|
||||
Example[Example["Value"] = 0] = "Value";
|
||||
})(Example || (Example = {}));
|
||||
|
||||
foo;
|
||||
3
packages/babel-preset-typescript/test/fixtures/flow-compat/tsx-invalid/input.tsx
vendored
Normal file
3
packages/babel-preset-typescript/test/fixtures/flow-compat/tsx-invalid/input.tsx
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
type Foo = {||};
|
||||
|
||||
foo;
|
||||
8
packages/babel-preset-typescript/test/fixtures/flow-compat/tsx-invalid/options.json
vendored
Normal file
8
packages/babel-preset-typescript/test/fixtures/flow-compat/tsx-invalid/options.json
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"presets": [
|
||||
["flow", {}, "before"],
|
||||
"typescript",
|
||||
["flow", {}, "after"]
|
||||
],
|
||||
"throws": "Unexpected token (1:12)"
|
||||
}
|
||||
5
packages/babel-preset-typescript/test/fixtures/flow-compat/tsx-valid/input.tsx
vendored
Normal file
5
packages/babel-preset-typescript/test/fixtures/flow-compat/tsx-valid/input.tsx
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
enum Example {
|
||||
Value
|
||||
}
|
||||
|
||||
foo;
|
||||
7
packages/babel-preset-typescript/test/fixtures/flow-compat/tsx-valid/output.js
vendored
Normal file
7
packages/babel-preset-typescript/test/fixtures/flow-compat/tsx-valid/output.js
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
var Example;
|
||||
|
||||
(function (Example) {
|
||||
Example[Example["Value"] = 0] = "Value";
|
||||
})(Example || (Example = {}));
|
||||
|
||||
foo;
|
||||
1
packages/babel-preset-typescript/test/fixtures/jsx-compat/js-valid/input.js
vendored
Normal file
1
packages/babel-preset-typescript/test/fixtures/jsx-compat/js-valid/input.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
(<div />);
|
||||
1
packages/babel-preset-typescript/test/fixtures/jsx-compat/js-valid/output.js
vendored
Normal file
1
packages/babel-preset-typescript/test/fixtures/jsx-compat/js-valid/output.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
React.createElement("div", null);
|
||||
7
packages/babel-preset-typescript/test/fixtures/jsx-compat/options.json
vendored
Normal file
7
packages/babel-preset-typescript/test/fixtures/jsx-compat/options.json
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"presets": [
|
||||
["react", {}, "before"],
|
||||
"typescript",
|
||||
["react", {}, "after"]
|
||||
]
|
||||
}
|
||||
1
packages/babel-preset-typescript/test/fixtures/jsx-compat/ts-invalid/input.ts
vendored
Normal file
1
packages/babel-preset-typescript/test/fixtures/jsx-compat/ts-invalid/input.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
(<div />);
|
||||
8
packages/babel-preset-typescript/test/fixtures/jsx-compat/ts-invalid/options.json
vendored
Normal file
8
packages/babel-preset-typescript/test/fixtures/jsx-compat/ts-invalid/options.json
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"presets": [
|
||||
["react", {}, "before"],
|
||||
"typescript",
|
||||
["react", {}, "after"]
|
||||
],
|
||||
"throws": "Unexpected token, expected \"</>\" (1:6)"
|
||||
}
|
||||
1
packages/babel-preset-typescript/test/fixtures/jsx-compat/tsx-valid/input.tsx
vendored
Normal file
1
packages/babel-preset-typescript/test/fixtures/jsx-compat/tsx-valid/input.tsx
vendored
Normal file
@ -0,0 +1 @@
|
||||
(<div />);
|
||||
1
packages/babel-preset-typescript/test/fixtures/jsx-compat/tsx-valid/output.js
vendored
Normal file
1
packages/babel-preset-typescript/test/fixtures/jsx-compat/tsx-valid/output.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
React.createElement("div", null);
|
||||
3
packages/babel-preset-typescript/test/index.js
Normal file
3
packages/babel-preset-typescript/test/index.js
Normal file
@ -0,0 +1,3 @@
|
||||
import runner from "@babel/helper-plugin-test-runner";
|
||||
|
||||
runner(__dirname);
|
||||
Loading…
x
Reference in New Issue
Block a user