Skip to content

Commit

Permalink
ensure only builders starting with lowercase are used
Browse files Browse the repository at this point in the history
  • Loading branch information
zxbodya committed Jun 6, 2020
1 parent 426acf3 commit 6c9beda
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
16 changes: 8 additions & 8 deletions packages/babel-generator/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,32 +463,32 @@ describe("programmatic generation", function() {

describe("typescript generate parentheses if necessary", function() {
it("wraps around union for array", () => {
const typeStatement = t.TSArrayType(
t.TSUnionType([
t.TSIntersectionType([t.TSNumberKeyword(), t.TSBooleanKeyword()]),
t.TSNullKeyword(),
const typeStatement = t.tsArrayType(
t.tsUnionType([
t.tsIntersectionType([t.tsNumberKeyword(), t.tsBooleanKeyword()]),
t.tsNullKeyword(),
]),
);
const output = generate(typeStatement).code;
expect(output).toBe("((number & boolean) | null)[]");
});
it("wraps around intersection for array", () => {
const typeStatement = t.TSArrayType(
t.TSIntersectionType([t.TSNumberKeyword(), t.TSBooleanKeyword()]),
const typeStatement = t.tsArrayType(
t.tsIntersectionType([t.tsNumberKeyword(), t.tsBooleanKeyword()]),
);
const output = generate(typeStatement).code;
expect(output).toBe("(number & boolean)[]");
});
it("wraps around rest", () => {
const typeStatement = t.tsRestType(
t.TSIntersectionType([t.TSNumberKeyword(), t.TSBooleanKeyword()]),
t.tsIntersectionType([t.tsNumberKeyword(), t.tsBooleanKeyword()]),
);
const output = generate(typeStatement).code;
expect(output).toBe("...(number & boolean)");
});
it("wraps around optional type", () => {
const typeStatement = t.tsOptionalType(
t.TSIntersectionType([t.TSNumberKeyword(), t.TSBooleanKeyword()]),
t.tsIntersectionType([t.tsNumberKeyword(), t.tsBooleanKeyword()]),
);
const output = generate(typeStatement).code;
expect(output).toBe("(number & boolean)?");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ exports.default = function(_ref) {
.forEach(function(decorator) {
resultantDecorator = types.callExpression(
decorator.expression,
[resultantDecorator || types.Identifier(paramUidName)]
[resultantDecorator || types.identifier(paramUidName)]
);
});

Expand All @@ -40,12 +40,12 @@ exports.default = function(_ref) {
"body",
types.variableDeclaration("var", [
types.variableDeclarator(
types.Identifier(decoratedParamUidName),
types.identifier(decoratedParamUidName),
resultantDecorator
),
])
);
param.replaceWith(types.Identifier(paramUidName));
param.replaceWith(types.identifier(paramUidName));
}
});
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TSUnionType } from "../generated";
import { tsUnionType } from "../generated";
import removeTypeDuplicates from "../../modifications/typescript/removeTypeDuplicates";

/**
Expand All @@ -14,6 +14,6 @@ export default function createTSUnionType(
if (flattened.length === 1) {
return flattened[0];
} else {
return TSUnionType(flattened);
return tsUnionType(flattened);
}
}

0 comments on commit 6c9beda

Please sign in to comment.