Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getTypePredicateOneWay(left, right, isStrictEquals) {
switch (right.kind) {
case ts.SyntaxKind.TypeOfExpression:
var expression = right.expression;
if (!tsutils_1.isLiteralExpression(left)) {
if ((tsutils_1.isIdentifier(left) && left.text === "undefined") ||
left.kind === ts.SyntaxKind.NullKeyword ||
left.kind === ts.SyntaxKind.TrueKeyword ||
left.kind === ts.SyntaxKind.FalseKeyword) {
return { kind: 2 /* TypeofTypo */ };
}
return undefined;
}
var predicate = getTypePredicateForKind(left.text);
return predicate === undefined
? { kind: 2 /* TypeofTypo */ }
: {
expression: expression,
isNullOrUndefined: left.text === "undefined",
kind: 0 /* Plain */,
predicate: predicate,
function getTypePredicateOneWay(left, right, isStrictEquals) {
switch (right.kind) {
case ts.SyntaxKind.TypeOfExpression:
var expression = right.expression;
if (!tsutils_1.isLiteralExpression(left)) {
if ((tsutils_1.isIdentifier(left) && left.text === "undefined") ||
left.kind === ts.SyntaxKind.NullKeyword ||
left.kind === ts.SyntaxKind.TrueKeyword ||
left.kind === ts.SyntaxKind.FalseKeyword) {
return { kind: 2 /* TypeofTypo */ };
}
return undefined;
}
var predicate = getTypePredicateForKind(left.text);
return predicate === undefined
? { kind: 2 /* TypeofTypo */ }
: {
expression: expression,
isNullOrUndefined: left.text === "undefined",
kind: 0 /* Plain */,
predicate: predicate,
function dependsOnPrevious(element: ts.BindingElement): boolean {
if (element.propertyName === undefined || element.propertyName.kind !== ts.SyntaxKind.ComputedPropertyName)
return false;
if (isIdentifier(element.propertyName.expression))
return identifiersSeen.has(element.propertyName.expression.text);
if (isLiteralExpression(element.propertyName.expression))
return false;
return true; // TODO implement better check for expressions
}
}
case ts.SyntaxKind.Constructor:
return "constructor";
case ts.SyntaxKind.CallSignature:
return "()";
default: {
const { name } = node;
if (name === undefined) {
return undefined;
}
switch (name.kind) {
case ts.SyntaxKind.Identifier:
return name.text;
case ts.SyntaxKind.ComputedPropertyName:
const { expression } = name;
return utils.isLiteralExpression(expression)
? expression.text
: { name: expression.getText(), computed: true };
default:
return utils.isLiteralExpression(name) ? name.text : undefined;
}
}
}
}
case ts.SyntaxKind.ConstructSignature:
case ts.SyntaxKind.Constructor:
return "constructor";
case ts.SyntaxKind.CallSignature:
return "()";
default: {
var name = node.name;
if (name === undefined) {
return undefined;
}
switch (name.kind) {
case ts.SyntaxKind.Identifier:
return name.text;
case ts.SyntaxKind.ComputedPropertyName:
var expression = name.expression;
return utils.isLiteralExpression(expression)
? expression.text
: { name: expression.getText(), computed: true };
default:
return utils.isLiteralExpression(name) ? name.text : undefined;
}
}
}
}
function getTypePredicateOneWay(
left: ts.Expression,
right: ts.Expression,
isStrictEquals: boolean,
): TypePredicate | undefined {
switch (right.kind) {
case ts.SyntaxKind.TypeOfExpression:
const expression = (right as ts.TypeOfExpression).expression;
if (!isLiteralExpression(left)) {
if (
(isIdentifier(left) && left.text === "undefined") ||
left.kind === ts.SyntaxKind.NullKeyword ||
left.kind === ts.SyntaxKind.TrueKeyword ||
left.kind === ts.SyntaxKind.FalseKeyword
) {
return { kind: TypePredicateKind.TypeofTypo };
}
return undefined;
}
const predicate = getTypePredicateForKind(left.text);
return predicate === undefined
? { kind: TypePredicateKind.TypeofTypo }
: {
expression,
isNullOrUndefined: left.text === "undefined",
case ts.SyntaxKind.ConstructSignature:
case ts.SyntaxKind.Constructor:
return "constructor";
case ts.SyntaxKind.CallSignature:
return "()";
default: {
var name = node.name;
if (name === undefined) {
return undefined;
}
switch (name.kind) {
case ts.SyntaxKind.Identifier:
return name.text;
case ts.SyntaxKind.ComputedPropertyName:
var expression = name.expression;
return utils.isLiteralExpression(expression)
? expression.text
: { name: expression.getText(), computed: true };
default:
return utils.isLiteralExpression(name) ? name.text : undefined;
}
}
}
}
var templateObject_1;
function isUndefinedNotVoidExpr(expression: ts.Expression): boolean {
if (utils.isIdentifier(expression) && expression.text === 'undefined')
return true;
return utils.isVoidExpression(expression) && utils.isLiteralExpression(expression.expression);
}
return "()";
default: {
var name = node.name;
if (name === undefined) {
return undefined;
}
switch (name.kind) {
case ts.SyntaxKind.Identifier:
return name.text;
case ts.SyntaxKind.ComputedPropertyName:
var expression = name.expression;
return utils.isLiteralExpression(expression)
? expression.text
: { name: expression.getText(), computed: true };
default:
return utils.isLiteralExpression(name) ? name.text : undefined;
}
}
}
}
var templateObject_1;