public class NoType extends NoObjectType
var x = null;
if (x) {
f(x);
}
We need to be able to assign x a type within the f(x)
call. Since it has no possible type, we assign x the NoType,
so that f(x) is legal no matter what the type of f's
first argument is.FunctionType.BuilderObjectType.PropertyOptionalityJSType.HasPropertyKind, JSType.Nullability, JSType.SubtypingMode, JSType.TypePairtemplateTypeMap| Modifier and Type | Method and Description |
|---|---|
BooleanLiteralSet |
getPossibleToBooleanOutcomes()
Computes the set of possible outcomes of the
ToBoolean predicate
for this type. |
boolean |
isNoObjectType() |
boolean |
isNoType() |
boolean |
isNullable()
Tests whether this type is nullable.
|
boolean |
isSubtype(JSType that)
A function is a subtype of another if their call methods are related via subtyping and
this is a subtype of that with regard to the prototype chain. |
protected boolean |
isSubtype(JSType that,
com.google.javascript.rhino.jstype.JSType.ImplCache implicitImplCache,
JSType.SubtypingMode subtypingMode)
checking isSubtype with structural interface matching
|
boolean |
isVoidable()
Tests whether this type is voidable.
|
<T> T |
visit(Visitor<T> visitor)
Visit this type with the given visitor.
|
getConstructor, getImplicitPrototype, getReferenceName, isConstructor, matchesNumberContext, matchesObjectContext, matchesStringContext, matchesSymbolContext, removeProperty, setPropertyJSDocInfo, toMaybeFunctionTypeacceptsArguments, builder, canBeCalled, checkExtendsLoop, clearCachedValues, forgetParameterAndReturnTypes, getAllImplementedInterfaces, getAncestorInterfaces, getBindReturnType, getClosurePrimitive, getConstructorOnlyTemplateParameters, getDirectSubTypes, getExtendedInterfaces, getExtendedInterfacesCount, getImplementedInterfaces, getInstanceType, getMaxArity, getMinArity, getOwnImplementedInterfaces, getOwnPropertyNames, getParameters, getParametersNode, getParameterTypes, getPropertyType, getPropertyTypeMap, getPrototype, getPrototypeProperty, getReturnType, getSlot, getSource, getSuperClassConstructor, getTypeOfThis, hasCachedValues, hasEqualCallType, hasImplementedInterfaces, hasInstanceType, hasProperties, isAbstract, isInstanceType, isInterface, isOrdinaryFunction, isReturnTypeInferred, isStructuralInterface, makesDicts, makesStructs, setDict, setExplicitUnrestricted, setExtendedInterfaces, setImplementedInterfaces, setImplicitMatch, setPrototypeBasedOn, setSource, setStruct, toDebugHashCodeStringgetCtorExtendedInterfaces, getCtorImplementedInterfaces, getOwnerFunction, isAnonymous, isNativeObjectType, matchConstraint, matchRecordTypeConstraint, setPropertyNode, unboxesTocast, createDelegateSuffix, defineDeclaredProperty, defineInferredProperty, defineSynthesizedProperty, findClosestDefinition, findPropertyTypeWithoutConsideringTemplateTypes, getClosestDefiningType, getDisplayName, getEnumeratedTypeOfEnumObject, getImplicitPrototypeChain, getJSDocInfo, getNormalizedReferenceName, getOwnPropertyDefSite, getOwnPropertyJSDocInfo, getOwnPropertyKind, getOwnSlot, getPropertiesCount, getPropertyDefSite, getPropertyJSDocInfo, getPropertyKind, getPropertyNames, getPropertyNode, getRawType, getTemplateTypes, getTopMostDefiningType, hasOwnProperty, hasReferenceName, instantiateGenericsWithUnknown, isAmbiguousObject, isFunctionPrototypeType, isObject, isPropertyInExterns, isPropertyTypeDeclared, isPropertyTypeInferred, isStructuralSubtypeHelper, isStructuralType, isUnknownType, setJSDocInfo, testForEqualityassertFunctionType, assertObjectType, autobox, autoboxesTo, canCastTo, canTestForEqualityWith, canTestForShallowEqualityWith, collapseUnion, dereference, differsFrom, equals, findPropertyType, getEnumeratedTypeOfEnumElement, getGreatestSubtype, getGreatestSubtypeWithProperty, getInstantiatedTypeArgument, getLeastSupertype, getPropertyKind, getRestrictedTypeGivenToBooleanOutcome, getTemplateTypeMap, getTypeParameters, getTypesUnderEquality, getTypesUnderInequality, getTypesUnderShallowEquality, getTypesUnderShallowInequality, getUnionMembers, hasAnyTemplateTypes, hasDisplayName, hashCode, hasProperty, isAllType, isArrayType, isBooleanObjectType, isBooleanValueType, isBoxableScalar, isCheckedUnknownType, isDateType, isDict, isEmptyType, isEnumElementType, isEnumType, isEquivalent, isEquivalentTo, isEquivalentTo, isExplicitlyVoidable, isFullyInstantiated, isFunctionType, isGenericObjectType, isGlobalThisType, isLiteralObject, isNamedType, isNominalConstructor, isNominalType, isNoResolvedType, isNullType, isNumber, isNumberObjectType, isNumberValueType, isObjectType, isPartiallyInstantiated, isRecordType, isRegexpType, isResolved, isSomeUnknownType, isString, isStringObjectType, isStringValueType, isStruct, isSubtype, isSubtypeOf, isSubtypeWithoutStructuralTyping, isSuccessfullyResolved, isSymbol, isSymbolObjectType, isSymbolValueType, isTemplateType, isTemplatizedType, isTypeVariable, isUnionType, isUnresolved, isUnresolvedOrResolvedUnknown, isUnsuccessfullyResolved, isVoidType, meetWith, prependTemplateTypeMap, resolve, restrictByNotNullOrUndefined, restrictByNotUndefined, setValidator, toAnnotationString, toMaybeEnumElementType, toMaybeEnumType, toMaybeFunctionType, toMaybeNamedType, toMaybeObjectType, toMaybeRecordType, toMaybeTemplateType, toMaybeTemplatizedType, toMaybeUnionType, toObjectType, toStringpublic final boolean isNoObjectType()
isNoObjectType in class NoObjectTypepublic final boolean isNullable()
JSTypeisNullable in class JSTypepublic final boolean isVoidable()
JSTypeisVoidable in class JSTypepublic boolean isSubtype(JSType that)
FunctionTypethis is a subtype of that with regard to the prototype chain.isSubtype in class NoObjectTypethis <: thatprotected boolean isSubtype(JSType that, com.google.javascript.rhino.jstype.JSType.ImplCache implicitImplCache, JSType.SubtypingMode subtypingMode)
JSTypeisSubtype in class NoObjectTypeimplicitImplCache - a cache that records the checked
or currently checking type pairs, for example, if previous
checking found that constructor C is a subtype of interface I,
then in the cache, table key <I,C> maps to IMPLEMENT status.public final BooleanLiteralSet getPossibleToBooleanOutcomes()
JSTypeToBoolean predicate
for this type. The ToBoolean predicate is defined by the ECMA-262
standard, 3rd edition. Its behavior for simple types can be
summarized by the following table:
| type | result |
|---|---|
undefined | {false} |
null | {false} |
boolean | {true, false} |
number | {true, false} |
string | {true, false} |
Object | {true} |
getPossibleToBooleanOutcomes in class ObjectTypepublic final <T> T visit(Visitor<T> visitor)
JSTypevisit in class NoObjectTypeVisitorCopyright © 2009-2019 Google. All Rights Reserved.