babel-plugin-spectypes
Advanced tools
Comparing version 0.0.21 to 0.0.22
@@ -37,9 +37,10 @@ "use strict"; | ||
for (const decl of path.node.declarations) { | ||
const spec = t.isIdentifier(decl.init) | ||
? decl.init.name | ||
: t.isCallExpression(decl.init) && t.isIdentifier(decl.init.callee) | ||
? decl.init.callee.name | ||
const declInit = t.isSequenceExpression(decl.init) ? decl.init.expressions[1] : decl.init; | ||
const spec = t.isIdentifier(declInit) | ||
? declInit.name | ||
: t.isCallExpression(declInit) && t.isIdentifier(declInit.callee) | ||
? declInit.callee.name | ||
: ''; | ||
if (spec in specNames && (0, ts_is_defined_1.isDefined)(decl.init) && t.isIdentifier(decl.id)) { | ||
const parsed = (0, parse_1.parse)(decl.init, { specNames }); | ||
if (spec in specNames && (0, ts_is_defined_1.isDefined)(declInit) && t.isIdentifier(decl.id)) { | ||
const parsed = (0, parse_1.parse)(declInit, { specNames }); | ||
if (parsed.tag === 'success') { | ||
@@ -57,3 +58,9 @@ const transformed = (0, transform_1.transform)(parsed.success, { | ||
}); | ||
decl.init = (0, parser_1.parseExpression)(transformed); | ||
const result = (0, parser_1.parseExpression)(transformed); | ||
if (t.isSequenceExpression(decl.init)) { | ||
decl.init.expressions[1] = result; | ||
} | ||
else { | ||
decl.init = result; | ||
} | ||
} | ||
@@ -60,0 +67,0 @@ else { |
{ | ||
"name": "babel-plugin-spectypes", | ||
"version": "0.0.21", | ||
"version": "0.0.22", | ||
"private": false, | ||
@@ -48,3 +48,3 @@ "description": "Babel plugin that compiles spectypes validators", | ||
"ts-is-record": "^2.0.3", | ||
"ts-micro-dict": "^8.0.3", | ||
"ts-micro-dict": "^8.1.5", | ||
"ts-tiny-invariant": "^1.0.5" | ||
@@ -51,0 +51,0 @@ }, |
@@ -46,10 +46,11 @@ import type babelCore from '@babel/core' | ||
for (const decl of path.node.declarations) { | ||
const spec = t.isIdentifier(decl.init) | ||
? decl.init.name | ||
: t.isCallExpression(decl.init) && t.isIdentifier(decl.init.callee) | ||
? decl.init.callee.name | ||
const declInit = t.isSequenceExpression(decl.init) ? decl.init.expressions[1] : decl.init | ||
const spec = t.isIdentifier(declInit) | ||
? declInit.name | ||
: t.isCallExpression(declInit) && t.isIdentifier(declInit.callee) | ||
? declInit.callee.name | ||
: '' | ||
if (spec in specNames && isDefined(decl.init) && t.isIdentifier(decl.id)) { | ||
const parsed = parse(decl.init, { specNames }) | ||
if (spec in specNames && isDefined(declInit) && t.isIdentifier(decl.id)) { | ||
const parsed = parse(declInit, { specNames }) | ||
@@ -73,3 +74,8 @@ if (parsed.tag === 'success') { | ||
decl.init = parseExpression(transformed) | ||
const result = parseExpression(transformed) | ||
if (t.isSequenceExpression(decl.init)) { | ||
decl.init.expressions[1] = result | ||
} else { | ||
decl.init = result | ||
} | ||
} else { | ||
@@ -76,0 +82,0 @@ throw path.buildCodeFrameError(parsed.failure) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
171065
2699