mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge pull request #6744 from Microsoft/removePredicateTypiness
Remove notion of predicates as types, move predicates back to signatures
This commit is contained in:
+122
-135
@@ -131,8 +131,8 @@ namespace ts {
|
||||
|
||||
const noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
|
||||
|
||||
const anySignature = createSignature(undefined, undefined, emptyArray, anyType, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false);
|
||||
const unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false);
|
||||
const anySignature = createSignature(undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false);
|
||||
const unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false);
|
||||
|
||||
const globals: SymbolTable = {};
|
||||
|
||||
@@ -1707,6 +1707,15 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
function typePredicateToString(typePredicate: TypePredicate, enclosingDeclaration?: Declaration, flags?: TypeFormatFlags): string {
|
||||
const writer = getSingleLineStringWriter();
|
||||
getSymbolDisplayBuilder().buildTypePredicateDisplay(typePredicate, writer, enclosingDeclaration, flags);
|
||||
const result = writer.string();
|
||||
releaseStringWriter(writer);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function getTypeAliasForTypeLiteral(type: Type): Symbol {
|
||||
if (type.symbol && type.symbol.flags & SymbolFlags.TypeLiteral) {
|
||||
let node = type.symbol.declarations[0].parent;
|
||||
@@ -1840,16 +1849,10 @@ namespace ts {
|
||||
function writeType(type: Type, flags: TypeFormatFlags) {
|
||||
// Write undefined/null type as any
|
||||
if (type.flags & TypeFlags.Intrinsic) {
|
||||
if (type.flags & TypeFlags.PredicateType) {
|
||||
buildTypePredicateDisplay(writer, (type as PredicateType).predicate);
|
||||
buildTypeDisplay((type as PredicateType).predicate.type, writer, enclosingDeclaration, flags, symbolStack);
|
||||
}
|
||||
else {
|
||||
// Special handling for unknown / resolving types, they should show up as any and not unknown or __resolving
|
||||
writer.writeKeyword(!(globalFlags & TypeFormatFlags.WriteOwnNameForAnyLike) && isTypeAny(type)
|
||||
? "any"
|
||||
: (<IntrinsicType>type).intrinsicName);
|
||||
}
|
||||
// Special handling for unknown / resolving types, they should show up as any and not unknown or __resolving
|
||||
writer.writeKeyword(!(globalFlags & TypeFormatFlags.WriteOwnNameForAnyLike) && isTypeAny(type)
|
||||
? "any"
|
||||
: (<IntrinsicType>type).intrinsicName);
|
||||
}
|
||||
else if (type.flags & TypeFlags.ThisType) {
|
||||
if (inObjectTypeLiteral) {
|
||||
@@ -2148,10 +2151,10 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags) {
|
||||
function buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags) {
|
||||
const targetSymbol = getTargetSymbol(symbol);
|
||||
if (targetSymbol.flags & SymbolFlags.Class || targetSymbol.flags & SymbolFlags.Interface || targetSymbol.flags & SymbolFlags.TypeAlias) {
|
||||
buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags);
|
||||
buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaration, flags);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2221,7 +2224,7 @@ namespace ts {
|
||||
writePunctuation(writer, SyntaxKind.CloseParenToken);
|
||||
}
|
||||
|
||||
function buildTypePredicateDisplay(writer: SymbolWriter, predicate: TypePredicate) {
|
||||
function buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]): void {
|
||||
if (isIdentifierTypePredicate(predicate)) {
|
||||
writer.writeParameter(predicate.parameterName);
|
||||
}
|
||||
@@ -2231,6 +2234,7 @@ namespace ts {
|
||||
writeSpace(writer);
|
||||
writeKeyword(writer, SyntaxKind.IsKeyword);
|
||||
writeSpace(writer);
|
||||
buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack);
|
||||
}
|
||||
|
||||
function buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, symbolStack?: Symbol[]) {
|
||||
@@ -2243,8 +2247,13 @@ namespace ts {
|
||||
}
|
||||
writeSpace(writer);
|
||||
|
||||
const returnType = getReturnTypeOfSignature(signature);
|
||||
buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack);
|
||||
if (signature.typePredicate) {
|
||||
buildTypePredicateDisplay(signature.typePredicate, writer, enclosingDeclaration, flags, symbolStack);
|
||||
}
|
||||
else {
|
||||
const returnType = getReturnTypeOfSignature(signature);
|
||||
buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack);
|
||||
}
|
||||
}
|
||||
|
||||
function buildSignatureDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind, symbolStack?: Symbol[]) {
|
||||
@@ -2263,6 +2272,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
buildDisplayForParametersAndDelimiters(signature.parameters, writer, enclosingDeclaration, flags, symbolStack);
|
||||
|
||||
buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack);
|
||||
}
|
||||
|
||||
@@ -2270,6 +2280,7 @@ namespace ts {
|
||||
buildSymbolDisplay,
|
||||
buildTypeDisplay,
|
||||
buildTypeParameterDisplay,
|
||||
buildTypePredicateDisplay,
|
||||
buildParameterDisplay,
|
||||
buildDisplayForParametersAndDelimiters,
|
||||
buildDisplayForTypeParametersAndDelimiters,
|
||||
@@ -2808,9 +2819,6 @@ namespace ts {
|
||||
if (declaration.kind === SyntaxKind.PropertyAssignment) {
|
||||
return type;
|
||||
}
|
||||
if (type.flags & TypeFlags.PredicateType && (declaration.kind === SyntaxKind.PropertyDeclaration || declaration.kind === SyntaxKind.PropertySignature)) {
|
||||
return type;
|
||||
}
|
||||
return getWidenedType(type);
|
||||
}
|
||||
|
||||
@@ -3541,12 +3549,13 @@ namespace ts {
|
||||
}
|
||||
|
||||
function createSignature(declaration: SignatureDeclaration, typeParameters: TypeParameter[], parameters: Symbol[],
|
||||
resolvedReturnType: Type, minArgumentCount: number, hasRestParameter: boolean, hasStringLiterals: boolean): Signature {
|
||||
resolvedReturnType: Type, typePredicate: TypePredicate, minArgumentCount: number, hasRestParameter: boolean, hasStringLiterals: boolean): Signature {
|
||||
const sig = new Signature(checker);
|
||||
sig.declaration = declaration;
|
||||
sig.typeParameters = typeParameters;
|
||||
sig.parameters = parameters;
|
||||
sig.resolvedReturnType = resolvedReturnType;
|
||||
sig.typePredicate = typePredicate;
|
||||
sig.minArgumentCount = minArgumentCount;
|
||||
sig.hasRestParameter = hasRestParameter;
|
||||
sig.hasStringLiterals = hasStringLiterals;
|
||||
@@ -3555,14 +3564,14 @@ namespace ts {
|
||||
|
||||
function cloneSignature(sig: Signature): Signature {
|
||||
return createSignature(sig.declaration, sig.typeParameters, sig.parameters, sig.resolvedReturnType,
|
||||
sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals);
|
||||
sig.typePredicate, sig.minArgumentCount, sig.hasRestParameter, sig.hasStringLiterals);
|
||||
}
|
||||
|
||||
function getDefaultConstructSignatures(classType: InterfaceType): Signature[] {
|
||||
const baseConstructorType = getBaseConstructorTypeOfClass(classType);
|
||||
const baseSignatures = getSignaturesOfType(baseConstructorType, SignatureKind.Construct);
|
||||
if (baseSignatures.length === 0) {
|
||||
return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false)];
|
||||
return [createSignature(undefined, classType.localTypeParameters, emptyArray, classType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasStringLiterals*/ false)];
|
||||
}
|
||||
const baseTypeNode = getBaseTypeNodeOfClass(classType);
|
||||
const typeArguments = map(baseTypeNode.typeArguments, getTypeFromTypeNode);
|
||||
@@ -4075,6 +4084,7 @@ namespace ts {
|
||||
let minArgumentCount = -1;
|
||||
const isJSConstructSignature = isJSDocConstructSignature(declaration);
|
||||
let returnType: Type = undefined;
|
||||
let typePredicate: TypePredicate = undefined;
|
||||
|
||||
// If this is a JSDoc construct signature, then skip the first parameter in the
|
||||
// parameter list. The first parameter represents the return type of the construct
|
||||
@@ -4118,6 +4128,9 @@ namespace ts {
|
||||
}
|
||||
else if (declaration.type) {
|
||||
returnType = getTypeFromTypeNode(declaration.type);
|
||||
if (declaration.type.kind === SyntaxKind.TypePredicate) {
|
||||
typePredicate = createTypePredicateFromTypePredicateNode(declaration.type as TypePredicateNode);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (declaration.parserContextFlags & ParserContextFlags.JavaScriptFile) {
|
||||
@@ -4139,7 +4152,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, minArgumentCount, hasRestParameter(declaration), hasStringLiterals);
|
||||
links.resolvedSignature = createSignature(declaration, typeParameters, parameters, returnType, typePredicate, minArgumentCount, hasRestParameter(declaration), hasStringLiterals);
|
||||
}
|
||||
return links.resolvedSignature;
|
||||
}
|
||||
@@ -4845,25 +4858,6 @@ namespace ts {
|
||||
return links.resolvedType;
|
||||
}
|
||||
|
||||
function getPredicateType(node: TypePredicateNode): Type {
|
||||
return createPredicateType(getSymbolOfNode(node), createTypePredicateFromTypePredicateNode(node));
|
||||
}
|
||||
|
||||
function createPredicateType(symbol: Symbol, predicate: ThisTypePredicate | IdentifierTypePredicate) {
|
||||
const type = createType(TypeFlags.Boolean | TypeFlags.PredicateType) as PredicateType;
|
||||
type.symbol = symbol;
|
||||
type.predicate = predicate;
|
||||
return type;
|
||||
}
|
||||
|
||||
function getTypeFromPredicateTypeNode(node: TypePredicateNode): Type {
|
||||
const links = getNodeLinks(node);
|
||||
if (!links.resolvedType) {
|
||||
links.resolvedType = getPredicateType(node);
|
||||
}
|
||||
return links.resolvedType;
|
||||
}
|
||||
|
||||
function getTypeFromTypeNode(node: TypeNode): Type {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.AnyKeyword:
|
||||
@@ -4888,7 +4882,7 @@ namespace ts {
|
||||
case SyntaxKind.JSDocTypeReference:
|
||||
return getTypeFromTypeReference(<TypeReferenceNode>node);
|
||||
case SyntaxKind.TypePredicate:
|
||||
return getTypeFromPredicateTypeNode(<TypePredicateNode>node);
|
||||
return booleanType;
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
return getTypeFromTypeReference(<ExpressionWithTypeArguments>node);
|
||||
case SyntaxKind.TypeQuery:
|
||||
@@ -5040,6 +5034,7 @@ namespace ts {
|
||||
|
||||
function instantiateSignature(signature: Signature, mapper: TypeMapper, eraseTypeParameters?: boolean): Signature {
|
||||
let freshTypeParameters: TypeParameter[];
|
||||
let freshTypePredicate: TypePredicate;
|
||||
if (signature.typeParameters && !eraseTypeParameters) {
|
||||
// First create a fresh set of type parameters, then include a mapping from the old to the
|
||||
// new type parameters in the mapper function. Finally store this mapper in the new type
|
||||
@@ -5050,9 +5045,13 @@ namespace ts {
|
||||
tp.mapper = mapper;
|
||||
}
|
||||
}
|
||||
if (signature.typePredicate) {
|
||||
freshTypePredicate = cloneTypePredicate(signature.typePredicate, mapper);
|
||||
}
|
||||
const result = createSignature(signature.declaration, freshTypeParameters,
|
||||
instantiateList(signature.parameters, mapper, instantiateSymbol),
|
||||
instantiateType(signature.resolvedReturnType, mapper),
|
||||
freshTypePredicate,
|
||||
signature.minArgumentCount, signature.hasRestParameter, signature.hasStringLiterals);
|
||||
result.target = signature;
|
||||
result.mapper = mapper;
|
||||
@@ -5122,10 +5121,6 @@ namespace ts {
|
||||
if (type.flags & TypeFlags.Intersection) {
|
||||
return getIntersectionType(instantiateList((<IntersectionType>type).types, mapper, instantiateType));
|
||||
}
|
||||
if (type.flags & TypeFlags.PredicateType) {
|
||||
const predicate = (type as PredicateType).predicate;
|
||||
return createPredicateType(type.symbol, cloneTypePredicate(predicate, mapper));
|
||||
}
|
||||
}
|
||||
return type;
|
||||
}
|
||||
@@ -5267,21 +5262,58 @@ namespace ts {
|
||||
const sourceReturnType = getReturnTypeOfSignature(source);
|
||||
|
||||
// The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions
|
||||
if (targetReturnType.flags & TypeFlags.PredicateType && (targetReturnType as PredicateType).predicate.kind === TypePredicateKind.Identifier) {
|
||||
if (!(sourceReturnType.flags & TypeFlags.PredicateType)) {
|
||||
if (target.typePredicate) {
|
||||
if (source.typePredicate) {
|
||||
result &= compareTypePredicateRelatedTo(source.typePredicate, target.typePredicate, reportErrors, errorReporter, compareTypes);
|
||||
}
|
||||
else if (isIdentifierTypePredicate(target.typePredicate)) {
|
||||
if (reportErrors) {
|
||||
errorReporter(Diagnostics.Signature_0_must_have_a_type_predicate, signatureToString(source));
|
||||
}
|
||||
return Ternary.False;
|
||||
}
|
||||
}
|
||||
else {
|
||||
result &= compareTypes(sourceReturnType, targetReturnType, reportErrors);
|
||||
}
|
||||
|
||||
result &= compareTypes(sourceReturnType, targetReturnType, reportErrors);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function compareTypePredicateRelatedTo(source: TypePredicate,
|
||||
target: TypePredicate,
|
||||
reportErrors: boolean,
|
||||
errorReporter: (d: DiagnosticMessage, arg0?: string, arg1?: string) => void,
|
||||
compareTypes: (s: Type, t: Type, reportErrors?: boolean) => Ternary): Ternary {
|
||||
if (source.kind !== target.kind) {
|
||||
if (reportErrors) {
|
||||
errorReporter(Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard);
|
||||
errorReporter(Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target));
|
||||
}
|
||||
return Ternary.False;
|
||||
}
|
||||
|
||||
if (source.kind === TypePredicateKind.Identifier) {
|
||||
const sourceIdentifierPredicate = source as IdentifierTypePredicate;
|
||||
const targetIdentifierPredicate = target as IdentifierTypePredicate;
|
||||
if (sourceIdentifierPredicate.parameterIndex !== targetIdentifierPredicate.parameterIndex) {
|
||||
if (reportErrors) {
|
||||
errorReporter(Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceIdentifierPredicate.parameterName, targetIdentifierPredicate.parameterName);
|
||||
errorReporter(Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target));
|
||||
}
|
||||
return Ternary.False;
|
||||
}
|
||||
}
|
||||
|
||||
const related = compareTypes(source.type, target.type, reportErrors);
|
||||
if (related === Ternary.False && reportErrors) {
|
||||
errorReporter(Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target));
|
||||
}
|
||||
return related;
|
||||
}
|
||||
|
||||
function isImplementationCompatibleWithOverload(implementation: Signature, overload: Signature): boolean {
|
||||
const erasedSource = getErasedSignature(implementation);
|
||||
const erasedTarget = getErasedSignature(overload);
|
||||
@@ -5408,33 +5440,6 @@ namespace ts {
|
||||
if (source === numberType && target.flags & TypeFlags.Enum) return Ternary.True;
|
||||
}
|
||||
if (source.flags & TypeFlags.Boolean && target.flags & TypeFlags.Boolean) {
|
||||
if (source.flags & TypeFlags.PredicateType && target.flags & TypeFlags.PredicateType) {
|
||||
const sourcePredicate = source as PredicateType;
|
||||
const targetPredicate = target as PredicateType;
|
||||
if (sourcePredicate.predicate.kind !== targetPredicate.predicate.kind) {
|
||||
if (reportErrors) {
|
||||
reportError(Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard);
|
||||
reportError(Diagnostics.Type_predicate_0_is_not_assignable_to_1, typeToString(source), typeToString(target));
|
||||
}
|
||||
return Ternary.False;
|
||||
}
|
||||
if (sourcePredicate.predicate.kind === TypePredicateKind.Identifier) {
|
||||
const sourceIdentifierPredicate = sourcePredicate.predicate as IdentifierTypePredicate;
|
||||
const targetIdentifierPredicate = targetPredicate.predicate as IdentifierTypePredicate;
|
||||
if (sourceIdentifierPredicate.parameterIndex !== targetIdentifierPredicate.parameterIndex) {
|
||||
if (reportErrors) {
|
||||
reportError(Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceIdentifierPredicate.parameterName, targetIdentifierPredicate.parameterName);
|
||||
reportError(Diagnostics.Type_predicate_0_is_not_assignable_to_1, typeToString(source), typeToString(target));
|
||||
}
|
||||
return Ternary.False;
|
||||
}
|
||||
}
|
||||
const related = isRelatedTo(sourcePredicate.predicate.type, targetPredicate.predicate.type, reportErrors, headMessage);
|
||||
if (related === Ternary.False && reportErrors) {
|
||||
reportError(Diagnostics.Type_predicate_0_is_not_assignable_to_1, typeToString(source), typeToString(target));
|
||||
}
|
||||
return related;
|
||||
}
|
||||
return Ternary.True;
|
||||
}
|
||||
|
||||
@@ -6289,9 +6294,6 @@ namespace ts {
|
||||
if (type.flags & (TypeFlags.Undefined | TypeFlags.Null)) {
|
||||
return anyType;
|
||||
}
|
||||
if (type.flags & TypeFlags.PredicateType) {
|
||||
return booleanType;
|
||||
}
|
||||
if (type.flags & TypeFlags.ObjectLiteral) {
|
||||
return getWidenedTypeOfObjectLiteral(type);
|
||||
}
|
||||
@@ -6519,11 +6521,6 @@ namespace ts {
|
||||
inferFromTypes(sourceTypes[i], targetTypes[i]);
|
||||
}
|
||||
}
|
||||
else if (source.flags & TypeFlags.PredicateType && target.flags & TypeFlags.PredicateType) {
|
||||
if ((source as PredicateType).predicate.kind === (target as PredicateType).predicate.kind) {
|
||||
inferFromTypes((source as PredicateType).predicate.type, (target as PredicateType).predicate.type);
|
||||
}
|
||||
}
|
||||
else if (source.flags & TypeFlags.Tuple && target.flags & TypeFlags.Tuple && (<TupleType>source).elementTypes.length === (<TupleType>target).elementTypes.length) {
|
||||
// If source and target are tuples of the same size, infer from element types
|
||||
const sourceTypes = (<TupleType>source).elementTypes;
|
||||
@@ -6619,7 +6616,13 @@ namespace ts {
|
||||
|
||||
function inferFromSignature(source: Signature, target: Signature) {
|
||||
forEachMatchingParameterType(source, target, inferFromTypes);
|
||||
inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target));
|
||||
|
||||
if (source.typePredicate && target.typePredicate && source.typePredicate.kind === target.typePredicate.kind) {
|
||||
inferFromTypes(source.typePredicate.type, target.typePredicate.type);
|
||||
}
|
||||
else {
|
||||
inferFromTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target));
|
||||
}
|
||||
}
|
||||
|
||||
function inferFromIndexTypes(source: Type, target: Type, sourceKind: IndexKind, targetKind: IndexKind) {
|
||||
@@ -7045,46 +7048,33 @@ namespace ts {
|
||||
return originalType;
|
||||
}
|
||||
|
||||
function narrowTypeByTypePredicate(type: Type, expr: CallExpression, assumeTrue: boolean): Type {
|
||||
function narrowTypeByTypePredicate(type: Type, callExpression: CallExpression, assumeTrue: boolean): Type {
|
||||
if (type.flags & TypeFlags.Any) {
|
||||
return type;
|
||||
}
|
||||
const signature = getResolvedSignature(expr);
|
||||
const predicateType = getReturnTypeOfSignature(signature);
|
||||
const signature = getResolvedSignature(callExpression);
|
||||
|
||||
if (!predicateType || !(predicateType.flags & TypeFlags.PredicateType)) {
|
||||
const predicate = signature.typePredicate;
|
||||
if (!predicate) {
|
||||
return type;
|
||||
}
|
||||
const predicate = (predicateType as PredicateType).predicate;
|
||||
|
||||
if (isIdentifierTypePredicate(predicate)) {
|
||||
const callExpression = expr as CallExpression;
|
||||
if (callExpression.arguments[predicate.parameterIndex] &&
|
||||
getSymbolAtTypePredicatePosition(callExpression.arguments[predicate.parameterIndex]) === symbol) {
|
||||
return getNarrowedType(type, predicate.type, assumeTrue);
|
||||
}
|
||||
}
|
||||
else {
|
||||
const expression = skipParenthesizedNodes(expr.expression);
|
||||
return narrowTypeByThisTypePredicate(type, predicate, expression, assumeTrue);
|
||||
const invokedExpression = skipParenthesizedNodes(callExpression.expression);
|
||||
return narrowTypeByThisTypePredicate(type, predicate, invokedExpression, assumeTrue);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
function narrowTypeByTypePredicateMember(type: Type, expr: ElementAccessExpression | PropertyAccessExpression, assumeTrue: boolean): Type {
|
||||
if (type.flags & TypeFlags.Any) {
|
||||
return type;
|
||||
}
|
||||
const memberType = getTypeOfExpression(expr);
|
||||
if (!(memberType.flags & TypeFlags.PredicateType)) {
|
||||
return type;
|
||||
}
|
||||
|
||||
return narrowTypeByThisTypePredicate(type, (memberType as PredicateType).predicate as ThisTypePredicate, expr, assumeTrue);
|
||||
}
|
||||
|
||||
function narrowTypeByThisTypePredicate(type: Type, predicate: ThisTypePredicate, expression: Expression, assumeTrue: boolean): Type {
|
||||
if (expression.kind === SyntaxKind.ElementAccessExpression || expression.kind === SyntaxKind.PropertyAccessExpression) {
|
||||
const accessExpression = expression as ElementAccessExpression | PropertyAccessExpression;
|
||||
function narrowTypeByThisTypePredicate(type: Type, predicate: ThisTypePredicate, invokedExpression: Expression, assumeTrue: boolean): Type {
|
||||
if (invokedExpression.kind === SyntaxKind.ElementAccessExpression || invokedExpression.kind === SyntaxKind.PropertyAccessExpression) {
|
||||
const accessExpression = invokedExpression as ElementAccessExpression | PropertyAccessExpression;
|
||||
const possibleIdentifier = skipParenthesizedNodes(accessExpression.expression);
|
||||
if (possibleIdentifier.kind === SyntaxKind.Identifier && getSymbolAtTypePredicatePosition(possibleIdentifier) === symbol) {
|
||||
return getNarrowedType(type, predicate.type, assumeTrue);
|
||||
@@ -7098,8 +7088,7 @@ namespace ts {
|
||||
switch (expr.kind) {
|
||||
case SyntaxKind.Identifier:
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
case SyntaxKind.QualifiedName:
|
||||
return getSymbolOfEntityNameOrPropertyAccessExpression(expr as Node as (EntityName | PropertyAccessExpression));
|
||||
return getSymbolOfEntityNameOrPropertyAccessExpression(expr as (Identifier | PropertyAccessExpression));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7131,9 +7120,6 @@ namespace ts {
|
||||
return narrowType(type, (<PrefixUnaryExpression>expr).operand, !assumeTrue);
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
return narrowTypeByTypePredicateMember(type, expr as (ElementAccessExpression | PropertyAccessExpression), assumeTrue);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
@@ -10608,12 +10594,13 @@ namespace ts {
|
||||
return aggregatedTypes;
|
||||
}
|
||||
|
||||
/*
|
||||
*TypeScript Specification 1.0 (6.3) - July 2014
|
||||
* An explicitly typed function whose return type isn't the Void type,
|
||||
* the Any type, or a union type containing the Void or Any type as a constituent
|
||||
* must have at least one return statement somewhere in its body.
|
||||
* An exception to this rule is if the function implementation consists of a single 'throw' statement.
|
||||
/**
|
||||
* TypeScript Specification 1.0 (6.3) - July 2014
|
||||
* An explicitly typed function whose return type isn't the Void type,
|
||||
* the Any type, or a union type containing the Void or Any type as a constituent
|
||||
* must have at least one return statement somewhere in its body.
|
||||
* An exception to this rule is if the function implementation consists of a single 'throw' statement.
|
||||
*
|
||||
* @param returnType - return type of the function, can be undefined if return type is not explicitly specified
|
||||
*/
|
||||
function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func: FunctionLikeDeclaration, returnType: Type): void {
|
||||
@@ -11630,21 +11617,24 @@ namespace ts {
|
||||
return -1;
|
||||
}
|
||||
|
||||
function checkTypePredicate(node: TypePredicateNode) {
|
||||
function checkTypePredicate(node: TypePredicateNode): void {
|
||||
const parent = getTypePredicateParent(node);
|
||||
if (!parent) {
|
||||
// The parent must not be valid.
|
||||
error(node, Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods);
|
||||
return;
|
||||
}
|
||||
const returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(parent));
|
||||
if (!returnType || !(returnType.flags & TypeFlags.PredicateType)) {
|
||||
|
||||
const typePredicate = getSignatureFromDeclaration(parent).typePredicate;
|
||||
if (!typePredicate) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { parameterName } = node;
|
||||
if (parameterName.kind === SyntaxKind.ThisType) {
|
||||
if (isThisTypePredicate(typePredicate)) {
|
||||
getTypeFromThisTypeNode(parameterName as ThisTypeNode);
|
||||
}
|
||||
else {
|
||||
const typePredicate = <IdentifierTypePredicate>(<PredicateType>returnType).predicate;
|
||||
if (typePredicate.parameterIndex >= 0) {
|
||||
if (parent.parameters[typePredicate.parameterIndex].dotDotDotToken) {
|
||||
error(parameterName,
|
||||
@@ -11659,12 +11649,8 @@ namespace ts {
|
||||
else if (parameterName) {
|
||||
let hasReportedError = false;
|
||||
for (const { name } of parent.parameters) {
|
||||
if ((name.kind === SyntaxKind.ObjectBindingPattern ||
|
||||
name.kind === SyntaxKind.ArrayBindingPattern) &&
|
||||
checkIfTypePredicateVariableIsDeclaredInBindingPattern(
|
||||
<BindingPattern>name,
|
||||
parameterName,
|
||||
typePredicate.parameterName)) {
|
||||
if (isBindingPattern(name) &&
|
||||
checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, parameterName, typePredicate.parameterName)) {
|
||||
hasReportedError = true;
|
||||
break;
|
||||
}
|
||||
@@ -11732,8 +11718,9 @@ namespace ts {
|
||||
|
||||
forEach(node.parameters, checkParameter);
|
||||
|
||||
checkSourceElement(node.type);
|
||||
|
||||
if (node.type) {
|
||||
checkSourceElement(node.type);
|
||||
}
|
||||
|
||||
if (produceDiagnostics) {
|
||||
checkCollisionWithArgumentsInGeneratedCode(node);
|
||||
@@ -13737,7 +13724,7 @@ namespace ts {
|
||||
error(node.expression, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class);
|
||||
}
|
||||
}
|
||||
else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || returnType.flags & TypeFlags.PredicateType) {
|
||||
else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func)) {
|
||||
if (isAsyncFunctionLike(func)) {
|
||||
const promisedType = getPromisedType(returnType);
|
||||
const awaitedType = checkAwaitedType(exprType, node.expression, Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member);
|
||||
|
||||
@@ -715,6 +715,10 @@
|
||||
"category": "Error",
|
||||
"code": 1227
|
||||
},
|
||||
"A type predicate is only allowed in return type position for functions and methods.": {
|
||||
"category": "Error",
|
||||
"code": 1228
|
||||
},
|
||||
"A type predicate cannot reference a rest parameter.": {
|
||||
"category": "Error",
|
||||
"code": 1229
|
||||
|
||||
@@ -1940,7 +1940,7 @@ namespace ts {
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseTypePredicate(lhs: Identifier | ThisTypeNode): TypePredicateNode {
|
||||
function parseThisTypePredicate(lhs: ThisTypeNode): TypePredicateNode {
|
||||
nextToken();
|
||||
const node = createNode(SyntaxKind.TypePredicate, lhs.pos) as TypePredicateNode;
|
||||
node.parameterName = lhs;
|
||||
@@ -2399,7 +2399,7 @@ namespace ts {
|
||||
case SyntaxKind.ThisKeyword: {
|
||||
const thisKeyword = parseThisTypeNode();
|
||||
if (token === SyntaxKind.IsKeyword && !scanner.hasPrecedingLineBreak()) {
|
||||
return parseTypePredicate(thisKeyword);
|
||||
return parseThisTypePredicate(thisKeyword);
|
||||
}
|
||||
else {
|
||||
return thisKeyword;
|
||||
|
||||
+10
-11
@@ -1777,7 +1777,8 @@ namespace ts {
|
||||
buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void;
|
||||
buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags): void;
|
||||
buildTypePredicateDisplay(predicate: TypePredicate, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildDisplayForParametersAndDelimiters(parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
|
||||
@@ -1842,22 +1843,24 @@ namespace ts {
|
||||
Identifier
|
||||
}
|
||||
|
||||
export interface TypePredicate {
|
||||
export interface TypePredicateBase {
|
||||
kind: TypePredicateKind;
|
||||
type: Type;
|
||||
}
|
||||
|
||||
// @kind (TypePredicateKind.This)
|
||||
export interface ThisTypePredicate extends TypePredicate {
|
||||
export interface ThisTypePredicate extends TypePredicateBase {
|
||||
_thisTypePredicateBrand: any;
|
||||
}
|
||||
|
||||
// @kind (TypePredicateKind.Identifier)
|
||||
export interface IdentifierTypePredicate extends TypePredicate {
|
||||
export interface IdentifierTypePredicate extends TypePredicateBase {
|
||||
parameterName: string;
|
||||
parameterIndex: number;
|
||||
}
|
||||
|
||||
export type TypePredicate = IdentifierTypePredicate | ThisTypePredicate;
|
||||
|
||||
/* @internal */
|
||||
export type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration;
|
||||
|
||||
@@ -2125,7 +2128,6 @@ namespace ts {
|
||||
ESSymbol = 0x01000000, // Type of symbol primitive introduced in ES6
|
||||
ThisType = 0x02000000, // This type
|
||||
ObjectLiteralPatternWithComputedProperties = 0x04000000, // Object literal type implied by binding pattern has computed properties
|
||||
PredicateType = 0x08000000, // Predicate types are also Boolean types, but should not be considered Intrinsics - there's no way to capture this with flags
|
||||
|
||||
/* @internal */
|
||||
Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null,
|
||||
@@ -2137,7 +2139,7 @@ namespace ts {
|
||||
UnionOrIntersection = Union | Intersection,
|
||||
StructuredType = ObjectType | Union | Intersection,
|
||||
/* @internal */
|
||||
RequiresWidening = ContainsUndefinedOrNull | ContainsObjectLiteral | PredicateType,
|
||||
RequiresWidening = ContainsUndefinedOrNull | ContainsObjectLiteral,
|
||||
/* @internal */
|
||||
PropagatingFlags = ContainsUndefinedOrNull | ContainsObjectLiteral | ContainsAnyFunctionType
|
||||
}
|
||||
@@ -2158,11 +2160,6 @@ namespace ts {
|
||||
intrinsicName: string; // Name of intrinsic type
|
||||
}
|
||||
|
||||
// Predicate types (TypeFlags.Predicate)
|
||||
export interface PredicateType extends Type {
|
||||
predicate: ThisTypePredicate | IdentifierTypePredicate;
|
||||
}
|
||||
|
||||
// String literal types (TypeFlags.StringLiteral)
|
||||
export interface StringLiteralType extends Type {
|
||||
text: string; // Text of string literal
|
||||
@@ -2297,6 +2294,8 @@ namespace ts {
|
||||
erasedSignatureCache?: Signature; // Erased version of signature (deferred)
|
||||
/* @internal */
|
||||
isolatedSignatureType?: ObjectType; // A manufactured type that just contains the signature for purposes of signature comparison
|
||||
/* @internal */
|
||||
typePredicate?: TypePredicate;
|
||||
}
|
||||
|
||||
export const enum IndexKind {
|
||||
|
||||
@@ -746,6 +746,10 @@ namespace ts {
|
||||
return predicate && predicate.kind === TypePredicateKind.Identifier;
|
||||
}
|
||||
|
||||
export function isThisTypePredicate(predicate: TypePredicate): predicate is ThisTypePredicate {
|
||||
return predicate && predicate.kind === TypePredicateKind.This;
|
||||
}
|
||||
|
||||
export function getContainingFunction(node: Node): FunctionLikeDeclaration {
|
||||
while (true) {
|
||||
node = node.parent;
|
||||
|
||||
@@ -4,7 +4,7 @@ var obj: Object;
|
||||
>Object : Object
|
||||
|
||||
if (ArrayBuffer.isView(obj)) {
|
||||
>ArrayBuffer.isView(obj) : arg is ArrayBufferView
|
||||
>ArrayBuffer.isView(obj) : boolean
|
||||
>ArrayBuffer.isView : (arg: any) => arg is ArrayBufferView
|
||||
>ArrayBuffer : ArrayBufferConstructor
|
||||
>isView : (arg: any) => arg is ArrayBufferView
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
//// [declarationEmitIdentifierPredicates01.ts]
|
||||
|
||||
export function f(x: any): x is number {
|
||||
return typeof x === "number";
|
||||
}
|
||||
|
||||
//// [declarationEmitIdentifierPredicates01.js]
|
||||
"use strict";
|
||||
function f(x) {
|
||||
return typeof x === "number";
|
||||
}
|
||||
exports.f = f;
|
||||
|
||||
|
||||
//// [declarationEmitIdentifierPredicates01.d.ts]
|
||||
export declare function f(x: any): x is number;
|
||||
@@ -0,0 +1,10 @@
|
||||
=== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitIdentifierPredicates01.ts ===
|
||||
|
||||
export function f(x: any): x is number {
|
||||
>f : Symbol(f, Decl(declarationEmitIdentifierPredicates01.ts, 0, 0))
|
||||
>x : Symbol(x, Decl(declarationEmitIdentifierPredicates01.ts, 1, 18))
|
||||
>x : Symbol(x, Decl(declarationEmitIdentifierPredicates01.ts, 1, 18))
|
||||
|
||||
return typeof x === "number";
|
||||
>x : Symbol(x, Decl(declarationEmitIdentifierPredicates01.ts, 1, 18))
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitIdentifierPredicates01.ts ===
|
||||
|
||||
export function f(x: any): x is number {
|
||||
>f : (x: any) => x is number
|
||||
>x : any
|
||||
>x : any
|
||||
|
||||
return typeof x === "number";
|
||||
>typeof x === "number" : boolean
|
||||
>typeof x : string
|
||||
>x : any
|
||||
>"number" : string
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
tests/cases/conformance/declarationEmit/typePredicates/declarationEmitIdentifierPredicatesWithPrivateName01.ts(6,33): error TS4060: Return type of exported function has or is using private name 'I'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitIdentifierPredicatesWithPrivateName01.ts (1 errors) ====
|
||||
|
||||
interface I {
|
||||
a: number;
|
||||
}
|
||||
|
||||
export function f(x: any): x is I {
|
||||
~
|
||||
!!! error TS4060: Return type of exported function has or is using private name 'I'.
|
||||
return typeof x.a === "number";
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
//// [declarationEmitIdentifierPredicatesWithPrivateName01.ts]
|
||||
|
||||
interface I {
|
||||
a: number;
|
||||
}
|
||||
|
||||
export function f(x: any): x is I {
|
||||
return typeof x.a === "number";
|
||||
}
|
||||
|
||||
//// [declarationEmitIdentifierPredicatesWithPrivateName01.js]
|
||||
"use strict";
|
||||
function f(x) {
|
||||
return typeof x.a === "number";
|
||||
}
|
||||
exports.f = f;
|
||||
@@ -0,0 +1,43 @@
|
||||
//// [declarationEmitThisPredicates01.ts]
|
||||
|
||||
export class C {
|
||||
m(): this is D {
|
||||
return this instanceof D;
|
||||
}
|
||||
}
|
||||
|
||||
export class D extends C {
|
||||
}
|
||||
|
||||
//// [declarationEmitThisPredicates01.js]
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.m = function () {
|
||||
return this instanceof D;
|
||||
};
|
||||
return C;
|
||||
}());
|
||||
exports.C = C;
|
||||
var D = (function (_super) {
|
||||
__extends(D, _super);
|
||||
function D() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return D;
|
||||
}(C));
|
||||
exports.D = D;
|
||||
|
||||
|
||||
//// [declarationEmitThisPredicates01.d.ts]
|
||||
export declare class C {
|
||||
m(): this is D;
|
||||
}
|
||||
export declare class D extends C {
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
=== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicates01.ts ===
|
||||
|
||||
export class C {
|
||||
>C : Symbol(C, Decl(declarationEmitThisPredicates01.ts, 0, 0))
|
||||
|
||||
m(): this is D {
|
||||
>m : Symbol(m, Decl(declarationEmitThisPredicates01.ts, 1, 16))
|
||||
>D : Symbol(D, Decl(declarationEmitThisPredicates01.ts, 5, 1))
|
||||
|
||||
return this instanceof D;
|
||||
>this : Symbol(C, Decl(declarationEmitThisPredicates01.ts, 0, 0))
|
||||
>D : Symbol(D, Decl(declarationEmitThisPredicates01.ts, 5, 1))
|
||||
}
|
||||
}
|
||||
|
||||
export class D extends C {
|
||||
>D : Symbol(D, Decl(declarationEmitThisPredicates01.ts, 5, 1))
|
||||
>C : Symbol(C, Decl(declarationEmitThisPredicates01.ts, 0, 0))
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
=== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicates01.ts ===
|
||||
|
||||
export class C {
|
||||
>C : C
|
||||
|
||||
m(): this is D {
|
||||
>m : () => this is D
|
||||
>D : D
|
||||
|
||||
return this instanceof D;
|
||||
>this instanceof D : boolean
|
||||
>this : this
|
||||
>D : typeof D
|
||||
}
|
||||
}
|
||||
|
||||
export class D extends C {
|
||||
>D : D
|
||||
>C : C
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicates02.ts(9,10): error TS2526: A 'this' type is available only in a non-static member of a class or interface.
|
||||
|
||||
|
||||
==== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicates02.ts (1 errors) ====
|
||||
|
||||
export interface Foo {
|
||||
a: string;
|
||||
b: number;
|
||||
c: boolean;
|
||||
}
|
||||
|
||||
export const obj = {
|
||||
m(): this is Foo {
|
||||
~~~~
|
||||
!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface.
|
||||
let dis = this as Foo;
|
||||
return dis.a != null && dis.b != null && dis.c != null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
//// [declarationEmitThisPredicates02.ts]
|
||||
|
||||
export interface Foo {
|
||||
a: string;
|
||||
b: number;
|
||||
c: boolean;
|
||||
}
|
||||
|
||||
export const obj = {
|
||||
m(): this is Foo {
|
||||
let dis = this as Foo;
|
||||
return dis.a != null && dis.b != null && dis.c != null;
|
||||
}
|
||||
}
|
||||
|
||||
//// [declarationEmitThisPredicates02.js]
|
||||
"use strict";
|
||||
exports.obj = {
|
||||
m: function () {
|
||||
var dis = this;
|
||||
return dis.a != null && dis.b != null && dis.c != null;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//// [declarationEmitThisPredicates02.d.ts]
|
||||
export interface Foo {
|
||||
a: string;
|
||||
b: number;
|
||||
c: boolean;
|
||||
}
|
||||
export declare const obj: {
|
||||
m(): this is Foo;
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName01.ts(3,18): error TS4055: Return type of public method from exported class has or is using private name 'D'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName01.ts (1 errors) ====
|
||||
|
||||
export class C {
|
||||
m(): this is D {
|
||||
~
|
||||
!!! error TS4055: Return type of public method from exported class has or is using private name 'D'.
|
||||
return this instanceof D;
|
||||
}
|
||||
}
|
||||
|
||||
class D extends C {
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
//// [declarationEmitThisPredicatesWithPrivateName01.ts]
|
||||
|
||||
export class C {
|
||||
m(): this is D {
|
||||
return this instanceof D;
|
||||
}
|
||||
}
|
||||
|
||||
class D extends C {
|
||||
}
|
||||
|
||||
//// [declarationEmitThisPredicatesWithPrivateName01.js]
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.m = function () {
|
||||
return this instanceof D;
|
||||
};
|
||||
return C;
|
||||
}());
|
||||
exports.C = C;
|
||||
var D = (function (_super) {
|
||||
__extends(D, _super);
|
||||
function D() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return D;
|
||||
}(C));
|
||||
@@ -0,0 +1,22 @@
|
||||
tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName02.ts(8,14): error TS4025: Exported variable 'obj' has or is using private name 'Foo'.
|
||||
tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName02.ts(9,10): error TS2526: A 'this' type is available only in a non-static member of a class or interface.
|
||||
|
||||
|
||||
==== tests/cases/conformance/declarationEmit/typePredicates/declarationEmitThisPredicatesWithPrivateName02.ts (2 errors) ====
|
||||
|
||||
interface Foo {
|
||||
a: string;
|
||||
b: number;
|
||||
c: boolean;
|
||||
}
|
||||
|
||||
export const obj = {
|
||||
~~~
|
||||
!!! error TS4025: Exported variable 'obj' has or is using private name 'Foo'.
|
||||
m(): this is Foo {
|
||||
~~~~
|
||||
!!! error TS2526: A 'this' type is available only in a non-static member of a class or interface.
|
||||
let dis = this as Foo;
|
||||
return dis.a != null && dis.b != null && dis.c != null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
//// [declarationEmitThisPredicatesWithPrivateName02.ts]
|
||||
|
||||
interface Foo {
|
||||
a: string;
|
||||
b: number;
|
||||
c: boolean;
|
||||
}
|
||||
|
||||
export const obj = {
|
||||
m(): this is Foo {
|
||||
let dis = this as Foo;
|
||||
return dis.a != null && dis.b != null && dis.c != null;
|
||||
}
|
||||
}
|
||||
|
||||
//// [declarationEmitThisPredicatesWithPrivateName02.js]
|
||||
"use strict";
|
||||
exports.obj = {
|
||||
m: function () {
|
||||
var dis = this;
|
||||
return dis.a != null && dis.b != null && dis.c != null;
|
||||
}
|
||||
};
|
||||
@@ -4,7 +4,7 @@ var maybeArray: number | number[];
|
||||
|
||||
|
||||
if (Array.isArray(maybeArray)) {
|
||||
>Array.isArray(maybeArray) : arg is any[]
|
||||
>Array.isArray(maybeArray) : boolean
|
||||
>Array.isArray : (arg: any) => arg is any[]
|
||||
>Array : ArrayConstructor
|
||||
>isArray : (arg: any) => arg is any[]
|
||||
|
||||
@@ -31,7 +31,7 @@ function f(foo: T) {
|
||||
>T : ("a" | "b")[] | "a" | "b"
|
||||
|
||||
if (isS(foo)) {
|
||||
>isS(foo) : t is "a" | "b"
|
||||
>isS(foo) : boolean
|
||||
>isS : (t: ("a" | "b")[] | "a" | "b") => t is "a" | "b"
|
||||
>foo : ("a" | "b")[] | "a" | "b"
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ let x: A = {
|
||||
}
|
||||
|
||||
if (hasKind(x, "A")) {
|
||||
>hasKind(x, "A") : entity is A
|
||||
>hasKind(x, "A") : boolean
|
||||
>hasKind : { (entity: Entity, kind: "A"): entity is A; (entity: Entity, kind: "B"): entity is B; (entity: Entity, kind: "A" | "B"): entity is Entity; }
|
||||
>x : A
|
||||
>"A" : "A"
|
||||
@@ -105,7 +105,7 @@ else {
|
||||
|
||||
if (!hasKind(x, "B")) {
|
||||
>!hasKind(x, "B") : boolean
|
||||
>hasKind(x, "B") : entity is B
|
||||
>hasKind(x, "B") : boolean
|
||||
>hasKind : { (entity: Entity, kind: "A"): entity is A; (entity: Entity, kind: "B"): entity is B; (entity: Entity, kind: "A" | "B"): entity is Entity; }
|
||||
>x : A
|
||||
>"B" : "B"
|
||||
|
||||
@@ -85,7 +85,7 @@ let x: A = {
|
||||
}
|
||||
|
||||
if (hasKind(x, "A")) {
|
||||
>hasKind(x, "A") : entity is A
|
||||
>hasKind(x, "A") : boolean
|
||||
>hasKind : { (entity: Entity, kind: "A"): entity is A; (entity: Entity, kind: "B"): entity is B; }
|
||||
>x : A
|
||||
>"A" : "A"
|
||||
@@ -102,7 +102,7 @@ else {
|
||||
|
||||
if (!hasKind(x, "B")) {
|
||||
>!hasKind(x, "B") : boolean
|
||||
>hasKind(x, "B") : entity is B
|
||||
>hasKind(x, "B") : boolean
|
||||
>hasKind : { (entity: Entity, kind: "A"): entity is A; (entity: Entity, kind: "B"): entity is B; }
|
||||
>x : A
|
||||
>"B" : "B"
|
||||
|
||||
@@ -54,7 +54,7 @@ var b: B;
|
||||
|
||||
// Basic
|
||||
if (isC(a)) {
|
||||
>isC(a) : p1 is C
|
||||
>isC(a) : boolean
|
||||
>isC : (p1: any) => p1 is C
|
||||
>a : A
|
||||
|
||||
@@ -70,7 +70,7 @@ var subType: C;
|
||||
>C : C
|
||||
|
||||
if(isA(subType)) {
|
||||
>isA(subType) : p1 is A
|
||||
>isA(subType) : boolean
|
||||
>isA : (p1: any) => p1 is A
|
||||
>subType : C
|
||||
|
||||
@@ -87,7 +87,7 @@ var union: A | B;
|
||||
>B : B
|
||||
|
||||
if(isA(union)) {
|
||||
>isA(union) : p1 is A
|
||||
>isA(union) : boolean
|
||||
>isA : (p1: any) => p1 is A
|
||||
>union : A | B
|
||||
|
||||
@@ -118,7 +118,7 @@ declare function isC_multipleParams(p1, p2): p1 is C;
|
||||
>C : C
|
||||
|
||||
if (isC_multipleParams(a, 0)) {
|
||||
>isC_multipleParams(a, 0) : p1 is C
|
||||
>isC_multipleParams(a, 0) : boolean
|
||||
>isC_multipleParams : (p1: any, p2: any) => p1 is C
|
||||
>a : A
|
||||
>0 : number
|
||||
@@ -197,7 +197,7 @@ declare function acceptingBoolean(a: boolean);
|
||||
acceptingBoolean(isA(a));
|
||||
>acceptingBoolean(isA(a)) : any
|
||||
>acceptingBoolean : (a: boolean) => any
|
||||
>isA(a) : p1 is A
|
||||
>isA(a) : boolean
|
||||
>isA : (p1: any) => p1 is A
|
||||
>a : A
|
||||
|
||||
@@ -223,8 +223,8 @@ let union2: C | B;
|
||||
let union3: boolean | B = isA(union2) || union2;
|
||||
>union3 : boolean | B
|
||||
>B : B
|
||||
>isA(union2) || union2 : p1 is A | B
|
||||
>isA(union2) : p1 is A
|
||||
>isA(union2) || union2 : boolean | B
|
||||
>isA(union2) : boolean
|
||||
>isA : (p1: any) => p1 is A
|
||||
>union2 : C | B
|
||||
>union2 : B
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(2,7): error TS2300: Duplicate identifier 'A'.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(15,12): error TS2322: Type 'string' is not assignable to type 'x is A'.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(15,12): error TS2322: Type 'string' is not assignable to type 'boolean'.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(18,55): error TS2304: Cannot find name 'x'.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(18,57): error TS1144: '{' or ';' expected.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(18,57): error TS2304: Cannot find name 'is'.
|
||||
@@ -43,9 +43,13 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(98,22)
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(98,22): error TS2304: Cannot find name 'is'.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(98,25): error TS1005: ';' expected.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(98,27): error TS1005: ';' expected.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(104,25): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(105,16): error TS2322: Type 'boolean' is not assignable to type 'D'.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(105,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(107,20): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(110,20): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(111,16): error TS2408: Setters cannot return a value.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(116,18): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(120,22): error TS2304: Cannot find name 'p1'.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(120,25): error TS1005: ';' expected.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(120,25): error TS2304: Cannot find name 'is'.
|
||||
@@ -57,7 +61,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(133,34
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39): error TS1230: A type predicate cannot reference element 'p1' in a binding pattern.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts (50 errors) ====
|
||||
==== tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts (54 errors) ====
|
||||
|
||||
class A {
|
||||
~
|
||||
@@ -76,7 +80,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39
|
||||
function hasANonBooleanReturnStatement(x): x is A {
|
||||
return '';
|
||||
~~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'x is A'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'boolean'.
|
||||
}
|
||||
|
||||
function hasTypeGuardTypeInsideTypeGuardType(x): x is x is A {
|
||||
@@ -245,6 +249,8 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39
|
||||
// Non-compatiable type predicate positions for signature declarations
|
||||
class D {
|
||||
constructor(p1: A): p1 is C {
|
||||
~~~~~~~
|
||||
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
return true;
|
||||
~~~~
|
||||
!!! error TS2322: Type 'boolean' is not assignable to type 'D'.
|
||||
@@ -252,9 +258,13 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39
|
||||
!!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class
|
||||
}
|
||||
get m1(p1: A): p1 is C {
|
||||
~~~~~~~
|
||||
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
return true;
|
||||
}
|
||||
set m2(p1: A): p1 is C {
|
||||
~~~~~~~
|
||||
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
return true;
|
||||
~~~~
|
||||
!!! error TS2408: Setters cannot return a value.
|
||||
@@ -263,6 +273,8 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39
|
||||
|
||||
interface I1 {
|
||||
new (p1: A): p1 is C;
|
||||
~~~~~~~
|
||||
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
}
|
||||
|
||||
interface I2 {
|
||||
|
||||
@@ -100,7 +100,7 @@ let test1: boolean = funA(isB);
|
||||
>isB : (p1: any) => p1 is B
|
||||
|
||||
if (funB(retC, a)) {
|
||||
>funB(retC, a) : p2 is C
|
||||
>funB(retC, a) : boolean
|
||||
>funB : <T>(p1: (p1: any) => T, p2: any) => p2 is T
|
||||
>retC : (x: any) => C
|
||||
>a : A
|
||||
@@ -118,7 +118,7 @@ let test2: B = funC(isB);
|
||||
>isB : (p1: any) => p1 is B
|
||||
|
||||
if (funD(isC, a)) {
|
||||
>funD(isC, a) : p2 is C
|
||||
>funD(isC, a) : boolean
|
||||
>funD : <T>(p1: (p1: any) => p1 is T, p2: any) => p2 is T
|
||||
>isC : (p1: any) => p1 is C
|
||||
>a : A
|
||||
|
||||
@@ -45,7 +45,7 @@ let a: RoyalGuard = new FollowerGuard();
|
||||
>FollowerGuard : typeof FollowerGuard
|
||||
|
||||
if (a.isLeader()) {
|
||||
>a.isLeader() : this is LeadGuard
|
||||
>a.isLeader() : boolean
|
||||
>a.isLeader : () => this is LeadGuard
|
||||
>a : RoyalGuard
|
||||
>isLeader : () => this is LeadGuard
|
||||
@@ -57,7 +57,7 @@ if (a.isLeader()) {
|
||||
>lead : () => void
|
||||
}
|
||||
else if (a.isFollower()) {
|
||||
>a.isFollower() : this is FollowerGuard
|
||||
>a.isFollower() : boolean
|
||||
>a.isFollower : () => this is FollowerGuard
|
||||
>a : RoyalGuard
|
||||
>isFollower : () => this is FollowerGuard
|
||||
@@ -78,7 +78,7 @@ let b: GuardInterface;
|
||||
>GuardInterface : GuardInterface
|
||||
|
||||
if (b.isLeader()) {
|
||||
>b.isLeader() : this is LeadGuard
|
||||
>b.isLeader() : boolean
|
||||
>b.isLeader : () => this is LeadGuard
|
||||
>b : GuardInterface
|
||||
>isLeader : () => this is LeadGuard
|
||||
@@ -90,7 +90,7 @@ if (b.isLeader()) {
|
||||
>lead : () => void
|
||||
}
|
||||
else if (b.isFollower()) {
|
||||
>b.isFollower() : this is FollowerGuard
|
||||
>b.isFollower() : boolean
|
||||
>b.isFollower : () => this is FollowerGuard
|
||||
>b : GuardInterface
|
||||
>isFollower : () => this is FollowerGuard
|
||||
@@ -103,8 +103,8 @@ else if (b.isFollower()) {
|
||||
}
|
||||
|
||||
if (((a.isLeader)())) {
|
||||
>((a.isLeader)()) : this is LeadGuard
|
||||
>(a.isLeader)() : this is LeadGuard
|
||||
>((a.isLeader)()) : boolean
|
||||
>(a.isLeader)() : boolean
|
||||
>(a.isLeader) : () => this is LeadGuard
|
||||
>a.isLeader : () => this is LeadGuard
|
||||
>a : RoyalGuard
|
||||
@@ -117,8 +117,8 @@ if (((a.isLeader)())) {
|
||||
>lead : () => void
|
||||
}
|
||||
else if (((a).isFollower())) {
|
||||
>((a).isFollower()) : this is FollowerGuard
|
||||
>(a).isFollower() : this is FollowerGuard
|
||||
>((a).isFollower()) : boolean
|
||||
>(a).isFollower() : boolean
|
||||
>(a).isFollower : () => this is FollowerGuard
|
||||
>(a) : RoyalGuard
|
||||
>a : RoyalGuard
|
||||
@@ -132,8 +132,8 @@ else if (((a).isFollower())) {
|
||||
}
|
||||
|
||||
if (((a["isLeader"])())) {
|
||||
>((a["isLeader"])()) : this is LeadGuard
|
||||
>(a["isLeader"])() : this is LeadGuard
|
||||
>((a["isLeader"])()) : boolean
|
||||
>(a["isLeader"])() : boolean
|
||||
>(a["isLeader"]) : () => this is LeadGuard
|
||||
>a["isLeader"] : () => this is LeadGuard
|
||||
>a : RoyalGuard
|
||||
@@ -146,8 +146,8 @@ if (((a["isLeader"])())) {
|
||||
>lead : () => void
|
||||
}
|
||||
else if (((a)["isFollower"]())) {
|
||||
>((a)["isFollower"]()) : this is FollowerGuard
|
||||
>(a)["isFollower"]() : this is FollowerGuard
|
||||
>((a)["isFollower"]()) : boolean
|
||||
>(a)["isFollower"]() : boolean
|
||||
>(a)["isFollower"] : () => this is FollowerGuard
|
||||
>(a) : RoyalGuard
|
||||
>a : RoyalGuard
|
||||
@@ -166,7 +166,7 @@ var holder2 = {a};
|
||||
>a : RoyalGuard
|
||||
|
||||
if (holder2.a.isLeader()) {
|
||||
>holder2.a.isLeader() : this is LeadGuard
|
||||
>holder2.a.isLeader() : boolean
|
||||
>holder2.a.isLeader : () => this is LeadGuard
|
||||
>holder2.a : RoyalGuard
|
||||
>holder2 : { a: RoyalGuard; }
|
||||
@@ -232,7 +232,7 @@ let guard = new ArrowGuard();
|
||||
>ArrowGuard : typeof ArrowGuard
|
||||
|
||||
if (guard.isElite()) {
|
||||
>guard.isElite() : this is ArrowElite
|
||||
>guard.isElite() : boolean
|
||||
>guard.isElite : () => this is ArrowElite
|
||||
>guard : ArrowGuard
|
||||
>isElite : () => this is ArrowElite
|
||||
@@ -244,7 +244,7 @@ if (guard.isElite()) {
|
||||
>defend : () => void
|
||||
}
|
||||
else if (guard.isMedic()) {
|
||||
>guard.isMedic() : this is ArrowMedic
|
||||
>guard.isMedic() : boolean
|
||||
>guard.isMedic : () => this is ArrowMedic
|
||||
>guard : ArrowGuard
|
||||
>isMedic : () => this is ArrowMedic
|
||||
@@ -297,7 +297,7 @@ let crate: Crate<{}>;
|
||||
>Crate : Crate<T>
|
||||
|
||||
if (crate.isSundries()) {
|
||||
>crate.isSundries() : this is Crate<Sundries>
|
||||
>crate.isSundries() : boolean
|
||||
>crate.isSundries : () => this is Crate<Sundries>
|
||||
>crate : Crate<{}>
|
||||
>isSundries : () => this is Crate<Sundries>
|
||||
@@ -312,7 +312,7 @@ if (crate.isSundries()) {
|
||||
>true : boolean
|
||||
}
|
||||
else if (crate.isSupplies()) {
|
||||
>crate.isSupplies() : this is Crate<Supplies>
|
||||
>crate.isSupplies() : boolean
|
||||
>crate.isSupplies : () => this is Crate<Supplies>
|
||||
>crate : Crate<{}>
|
||||
>isSupplies : () => this is Crate<Supplies>
|
||||
@@ -405,7 +405,7 @@ a.isFollower = mimic.isFollower;
|
||||
>isFollower : () => this is MimicFollower
|
||||
|
||||
if (mimic.isFollower()) {
|
||||
>mimic.isFollower() : this is MimicFollower
|
||||
>mimic.isFollower() : boolean
|
||||
>mimic.isFollower : () => this is MimicFollower
|
||||
>mimic : MimicGuard
|
||||
>isFollower : () => this is MimicFollower
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
//// [typeGuardOfFormFunctionEquality.ts]
|
||||
declare function isString1(a: number, b: Object): b is string;
|
||||
|
||||
declare function isString2(a: Object): a is string;
|
||||
|
||||
switch (isString1(0, "")) {
|
||||
case isString2(""):
|
||||
default:
|
||||
}
|
||||
|
||||
var x = isString1(0, "") === isString2("");
|
||||
|
||||
function isString3(a: number, b: number, c: Object): c is string {
|
||||
return isString1(0, c);
|
||||
}
|
||||
|
||||
|
||||
//// [typeGuardOfFormFunctionEquality.js]
|
||||
switch (isString1(0, "")) {
|
||||
case isString2(""):
|
||||
default:
|
||||
}
|
||||
var x = isString1(0, "") === isString2("");
|
||||
function isString3(a, b, c) {
|
||||
return isString1(0, c);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
=== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormFunctionEquality.ts ===
|
||||
declare function isString1(a: number, b: Object): b is string;
|
||||
>isString1 : Symbol(isString1, Decl(typeGuardOfFormFunctionEquality.ts, 0, 0))
|
||||
>a : Symbol(a, Decl(typeGuardOfFormFunctionEquality.ts, 0, 27))
|
||||
>b : Symbol(b, Decl(typeGuardOfFormFunctionEquality.ts, 0, 37))
|
||||
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>b : Symbol(b, Decl(typeGuardOfFormFunctionEquality.ts, 0, 37))
|
||||
|
||||
declare function isString2(a: Object): a is string;
|
||||
>isString2 : Symbol(isString2, Decl(typeGuardOfFormFunctionEquality.ts, 0, 62))
|
||||
>a : Symbol(a, Decl(typeGuardOfFormFunctionEquality.ts, 2, 27))
|
||||
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>a : Symbol(a, Decl(typeGuardOfFormFunctionEquality.ts, 2, 27))
|
||||
|
||||
switch (isString1(0, "")) {
|
||||
>isString1 : Symbol(isString1, Decl(typeGuardOfFormFunctionEquality.ts, 0, 0))
|
||||
|
||||
case isString2(""):
|
||||
>isString2 : Symbol(isString2, Decl(typeGuardOfFormFunctionEquality.ts, 0, 62))
|
||||
|
||||
default:
|
||||
}
|
||||
|
||||
var x = isString1(0, "") === isString2("");
|
||||
>x : Symbol(x, Decl(typeGuardOfFormFunctionEquality.ts, 9, 3))
|
||||
>isString1 : Symbol(isString1, Decl(typeGuardOfFormFunctionEquality.ts, 0, 0))
|
||||
>isString2 : Symbol(isString2, Decl(typeGuardOfFormFunctionEquality.ts, 0, 62))
|
||||
|
||||
function isString3(a: number, b: number, c: Object): c is string {
|
||||
>isString3 : Symbol(isString3, Decl(typeGuardOfFormFunctionEquality.ts, 9, 43))
|
||||
>a : Symbol(a, Decl(typeGuardOfFormFunctionEquality.ts, 11, 19))
|
||||
>b : Symbol(b, Decl(typeGuardOfFormFunctionEquality.ts, 11, 29))
|
||||
>c : Symbol(c, Decl(typeGuardOfFormFunctionEquality.ts, 11, 40))
|
||||
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
>c : Symbol(c, Decl(typeGuardOfFormFunctionEquality.ts, 11, 40))
|
||||
|
||||
return isString1(0, c);
|
||||
>isString1 : Symbol(isString1, Decl(typeGuardOfFormFunctionEquality.ts, 0, 0))
|
||||
>c : Symbol(c, Decl(typeGuardOfFormFunctionEquality.ts, 11, 40))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
=== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormFunctionEquality.ts ===
|
||||
declare function isString1(a: number, b: Object): b is string;
|
||||
>isString1 : (a: number, b: Object) => b is string
|
||||
>a : number
|
||||
>b : Object
|
||||
>Object : Object
|
||||
>b : any
|
||||
|
||||
declare function isString2(a: Object): a is string;
|
||||
>isString2 : (a: Object) => a is string
|
||||
>a : Object
|
||||
>Object : Object
|
||||
>a : any
|
||||
|
||||
switch (isString1(0, "")) {
|
||||
>isString1(0, "") : boolean
|
||||
>isString1 : (a: number, b: Object) => b is string
|
||||
>0 : number
|
||||
>"" : string
|
||||
|
||||
case isString2(""):
|
||||
>isString2("") : boolean
|
||||
>isString2 : (a: Object) => a is string
|
||||
>"" : string
|
||||
|
||||
default:
|
||||
}
|
||||
|
||||
var x = isString1(0, "") === isString2("");
|
||||
>x : boolean
|
||||
>isString1(0, "") === isString2("") : boolean
|
||||
>isString1(0, "") : boolean
|
||||
>isString1 : (a: number, b: Object) => b is string
|
||||
>0 : number
|
||||
>"" : string
|
||||
>isString2("") : boolean
|
||||
>isString2 : (a: Object) => a is string
|
||||
>"" : string
|
||||
|
||||
function isString3(a: number, b: number, c: Object): c is string {
|
||||
>isString3 : (a: number, b: number, c: Object) => c is string
|
||||
>a : number
|
||||
>b : number
|
||||
>c : Object
|
||||
>Object : Object
|
||||
>c : any
|
||||
|
||||
return isString1(0, c);
|
||||
>isString1(0, c) : boolean
|
||||
>isString1 : (a: number, b: Object) => b is string
|
||||
>0 : number
|
||||
>c : Object
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ str = isC1(c1Orc2) && c1Orc2.p1; // C1
|
||||
>str = isC1(c1Orc2) && c1Orc2.p1 : string
|
||||
>str : string
|
||||
>isC1(c1Orc2) && c1Orc2.p1 : string
|
||||
>isC1(c1Orc2) : x is C1
|
||||
>isC1(c1Orc2) : boolean
|
||||
>isC1 : (x: any) => x is C1
|
||||
>c1Orc2 : C1 | C2
|
||||
>c1Orc2.p1 : string
|
||||
@@ -78,7 +78,7 @@ num = isC2(c1Orc2) && c1Orc2.p2; // C2
|
||||
>num = isC2(c1Orc2) && c1Orc2.p2 : number
|
||||
>num : number
|
||||
>isC2(c1Orc2) && c1Orc2.p2 : number
|
||||
>isC2(c1Orc2) : x is C2
|
||||
>isC2(c1Orc2) : boolean
|
||||
>isC2 : (x: any) => x is C2
|
||||
>c1Orc2 : C1 | C2
|
||||
>c1Orc2.p2 : number
|
||||
@@ -89,7 +89,7 @@ str = isD1(c1Orc2) && c1Orc2.p1; // D1
|
||||
>str = isD1(c1Orc2) && c1Orc2.p1 : string
|
||||
>str : string
|
||||
>isD1(c1Orc2) && c1Orc2.p1 : string
|
||||
>isD1(c1Orc2) : x is D1
|
||||
>isD1(c1Orc2) : boolean
|
||||
>isD1 : (x: any) => x is D1
|
||||
>c1Orc2 : C1 | C2
|
||||
>c1Orc2.p1 : string
|
||||
@@ -100,7 +100,7 @@ num = isD1(c1Orc2) && c1Orc2.p3; // D1
|
||||
>num = isD1(c1Orc2) && c1Orc2.p3 : number
|
||||
>num : number
|
||||
>isD1(c1Orc2) && c1Orc2.p3 : number
|
||||
>isD1(c1Orc2) : x is D1
|
||||
>isD1(c1Orc2) : boolean
|
||||
>isD1 : (x: any) => x is D1
|
||||
>c1Orc2 : C1 | C2
|
||||
>c1Orc2.p3 : number
|
||||
@@ -116,7 +116,7 @@ num = isC2(c2Ord1) && c2Ord1.p2; // C2
|
||||
>num = isC2(c2Ord1) && c2Ord1.p2 : number
|
||||
>num : number
|
||||
>isC2(c2Ord1) && c2Ord1.p2 : number
|
||||
>isC2(c2Ord1) : x is C2
|
||||
>isC2(c2Ord1) : boolean
|
||||
>isC2 : (x: any) => x is C2
|
||||
>c2Ord1 : C2 | D1
|
||||
>c2Ord1.p2 : number
|
||||
@@ -127,7 +127,7 @@ num = isD1(c2Ord1) && c2Ord1.p3; // D1
|
||||
>num = isD1(c2Ord1) && c2Ord1.p3 : number
|
||||
>num : number
|
||||
>isD1(c2Ord1) && c2Ord1.p3 : number
|
||||
>isD1(c2Ord1) : x is D1
|
||||
>isD1(c2Ord1) : boolean
|
||||
>isD1 : (x: any) => x is D1
|
||||
>c2Ord1 : C2 | D1
|
||||
>c2Ord1.p3 : number
|
||||
@@ -138,7 +138,7 @@ str = isD1(c2Ord1) && c2Ord1.p1; // D1
|
||||
>str = isD1(c2Ord1) && c2Ord1.p1 : string
|
||||
>str : string
|
||||
>isD1(c2Ord1) && c2Ord1.p1 : string
|
||||
>isD1(c2Ord1) : x is D1
|
||||
>isD1(c2Ord1) : boolean
|
||||
>isD1 : (x: any) => x is D1
|
||||
>c2Ord1 : C2 | D1
|
||||
>c2Ord1.p1 : string
|
||||
@@ -150,7 +150,7 @@ var r2: C2 | D1 = isC1(c2Ord1) && c2Ord1; // C2 | D1
|
||||
>C2 : C2
|
||||
>D1 : D1
|
||||
>isC1(c2Ord1) && c2Ord1 : D1
|
||||
>isC1(c2Ord1) : x is C1
|
||||
>isC1(c2Ord1) : boolean
|
||||
>isC1 : (x: any) => x is C1
|
||||
>c2Ord1 : C2 | D1
|
||||
>c2Ord1 : D1
|
||||
|
||||
@@ -98,7 +98,7 @@ str = isC1(c1Orc2) && c1Orc2.p1; // C1
|
||||
>str = isC1(c1Orc2) && c1Orc2.p1 : string
|
||||
>str : string
|
||||
>isC1(c1Orc2) && c1Orc2.p1 : string
|
||||
>isC1(c1Orc2) : x is C1
|
||||
>isC1(c1Orc2) : boolean
|
||||
>isC1 : (x: any) => x is C1
|
||||
>c1Orc2 : C1 | C2
|
||||
>c1Orc2.p1 : string
|
||||
@@ -109,7 +109,7 @@ num = isC2(c1Orc2) && c1Orc2.p2; // C2
|
||||
>num = isC2(c1Orc2) && c1Orc2.p2 : number
|
||||
>num : number
|
||||
>isC2(c1Orc2) && c1Orc2.p2 : number
|
||||
>isC2(c1Orc2) : x is C2
|
||||
>isC2(c1Orc2) : boolean
|
||||
>isC2 : (x: any) => x is C2
|
||||
>c1Orc2 : C1 | C2
|
||||
>c1Orc2.p2 : number
|
||||
@@ -120,7 +120,7 @@ str = isD1(c1Orc2) && c1Orc2.p1; // D1
|
||||
>str = isD1(c1Orc2) && c1Orc2.p1 : string
|
||||
>str : string
|
||||
>isD1(c1Orc2) && c1Orc2.p1 : string
|
||||
>isD1(c1Orc2) : x is D1
|
||||
>isD1(c1Orc2) : boolean
|
||||
>isD1 : (x: any) => x is D1
|
||||
>c1Orc2 : C1 | C2
|
||||
>c1Orc2.p1 : string
|
||||
@@ -131,7 +131,7 @@ num = isD1(c1Orc2) && c1Orc2.p3; // D1
|
||||
>num = isD1(c1Orc2) && c1Orc2.p3 : number
|
||||
>num : number
|
||||
>isD1(c1Orc2) && c1Orc2.p3 : number
|
||||
>isD1(c1Orc2) : x is D1
|
||||
>isD1(c1Orc2) : boolean
|
||||
>isD1 : (x: any) => x is D1
|
||||
>c1Orc2 : C1 | C2
|
||||
>c1Orc2.p3 : number
|
||||
@@ -147,7 +147,7 @@ num = isC2(c2Ord1) && c2Ord1.p2; // C2
|
||||
>num = isC2(c2Ord1) && c2Ord1.p2 : number
|
||||
>num : number
|
||||
>isC2(c2Ord1) && c2Ord1.p2 : number
|
||||
>isC2(c2Ord1) : x is C2
|
||||
>isC2(c2Ord1) : boolean
|
||||
>isC2 : (x: any) => x is C2
|
||||
>c2Ord1 : C2 | D1
|
||||
>c2Ord1.p2 : number
|
||||
@@ -158,7 +158,7 @@ num = isD1(c2Ord1) && c2Ord1.p3; // D1
|
||||
>num = isD1(c2Ord1) && c2Ord1.p3 : number
|
||||
>num : number
|
||||
>isD1(c2Ord1) && c2Ord1.p3 : number
|
||||
>isD1(c2Ord1) : x is D1
|
||||
>isD1(c2Ord1) : boolean
|
||||
>isD1 : (x: any) => x is D1
|
||||
>c2Ord1 : C2 | D1
|
||||
>c2Ord1.p3 : number
|
||||
@@ -169,7 +169,7 @@ str = isD1(c2Ord1) && c2Ord1.p1; // D1
|
||||
>str = isD1(c2Ord1) && c2Ord1.p1 : string
|
||||
>str : string
|
||||
>isD1(c2Ord1) && c2Ord1.p1 : string
|
||||
>isD1(c2Ord1) : x is D1
|
||||
>isD1(c2Ord1) : boolean
|
||||
>isD1 : (x: any) => x is D1
|
||||
>c2Ord1 : C2 | D1
|
||||
>c2Ord1.p1 : string
|
||||
@@ -181,7 +181,7 @@ var r2: C2 | D1 = isC1(c2Ord1) && c2Ord1; // C2 | D1
|
||||
>C2 : C2
|
||||
>D1 : D1
|
||||
>isC1(c2Ord1) && c2Ord1 : D1
|
||||
>isC1(c2Ord1) : x is C1
|
||||
>isC1(c2Ord1) : boolean
|
||||
>isC1 : (x: any) => x is C1
|
||||
>c2Ord1 : C2 | D1
|
||||
>c2Ord1 : D1
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts(4,10): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts(5,17): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts(11,22): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts(14,16): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts(34,8): error TS2339: Property 'content' does not exist on type 'FileSystemObject'.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts(36,9): error TS2339: Property 'host' does not exist on type 'FileSystemObject'.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts(37,9): error TS2339: Property 'content' does not exist on type 'FileSystemObject'.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts(41,8): error TS2339: Property 'children' does not exist on type 'FileSystemObject'.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts(44,8): error TS2339: Property 'host' does not exist on type 'FileSystemObject'.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts(57,13): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts(58,15): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts(63,9): error TS2339: Property 'lead' does not exist on type 'GenericGuard<File>'.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts(66,9): error TS2339: Property 'follow' does not exist on type 'GenericGuard<File>'.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts(70,19): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts(79,11): error TS2339: Property 'do' does not exist on type 'SpecificGuard'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts (15 errors) ====
|
||||
// There's a 'File' class in the stdlib, wrap with a namespace to avoid collision
|
||||
namespace Test {
|
||||
export class FileSystemObject {
|
||||
isFSO: this is FileSystemObject;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
get isFile(): this is File {
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
return this instanceof File;
|
||||
}
|
||||
set isFile(param) {
|
||||
// noop
|
||||
}
|
||||
get isDirectory(): this is Directory {
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
return this instanceof Directory;
|
||||
}
|
||||
isNetworked: this is (Networked & this);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
constructor(public path: string) {}
|
||||
}
|
||||
|
||||
export class File extends FileSystemObject {
|
||||
constructor(path: string, public content: string) { super(path); }
|
||||
}
|
||||
export class Directory extends FileSystemObject {
|
||||
children: FileSystemObject[];
|
||||
}
|
||||
export interface Networked {
|
||||
host: string;
|
||||
}
|
||||
|
||||
let file: FileSystemObject = new File("foo/bar.txt", "foo");
|
||||
file.isNetworked = false;
|
||||
file.isFSO = file.isFile;
|
||||
file.isFile = true;
|
||||
let x = file.isFile;
|
||||
if (file.isFile) {
|
||||
file.content;
|
||||
~~~~~~~
|
||||
!!! error TS2339: Property 'content' does not exist on type 'FileSystemObject'.
|
||||
if (file.isNetworked) {
|
||||
file.host;
|
||||
~~~~
|
||||
!!! error TS2339: Property 'host' does not exist on type 'FileSystemObject'.
|
||||
file.content;
|
||||
~~~~~~~
|
||||
!!! error TS2339: Property 'content' does not exist on type 'FileSystemObject'.
|
||||
}
|
||||
}
|
||||
else if (file.isDirectory) {
|
||||
file.children;
|
||||
~~~~~~~~
|
||||
!!! error TS2339: Property 'children' does not exist on type 'FileSystemObject'.
|
||||
}
|
||||
else if (file.isNetworked) {
|
||||
file.host;
|
||||
~~~~
|
||||
!!! error TS2339: Property 'host' does not exist on type 'FileSystemObject'.
|
||||
}
|
||||
|
||||
interface GenericLeadGuard<T> extends GenericGuard<T> {
|
||||
lead(): void;
|
||||
}
|
||||
|
||||
interface GenericFollowerGuard<T> extends GenericGuard<T> {
|
||||
follow(): void;
|
||||
}
|
||||
|
||||
interface GenericGuard<T> {
|
||||
target: T;
|
||||
isLeader: this is (GenericLeadGuard<T>);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
isFollower: this is GenericFollowerGuard<T>;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
}
|
||||
|
||||
let guard: GenericGuard<File>;
|
||||
if (guard.isLeader) {
|
||||
guard.lead();
|
||||
~~~~
|
||||
!!! error TS2339: Property 'lead' does not exist on type 'GenericGuard<File>'.
|
||||
}
|
||||
else if (guard.isFollower) {
|
||||
guard.follow();
|
||||
~~~~~~
|
||||
!!! error TS2339: Property 'follow' does not exist on type 'GenericGuard<File>'.
|
||||
}
|
||||
|
||||
interface SpecificGuard {
|
||||
isMoreSpecific: this is MoreSpecificGuard;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
}
|
||||
|
||||
interface MoreSpecificGuard extends SpecificGuard {
|
||||
do(): void;
|
||||
}
|
||||
|
||||
let general: SpecificGuard;
|
||||
if (general.isMoreSpecific) {
|
||||
general.do();
|
||||
~~
|
||||
!!! error TS2339: Property 'do' does not exist on type 'SpecificGuard'.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,240 +0,0 @@
|
||||
=== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts ===
|
||||
// There's a 'File' class in the stdlib, wrap with a namespace to avoid collision
|
||||
namespace Test {
|
||||
>Test : Symbol(Test, Decl(typeGuardOfFormThisMember.ts, 0, 0))
|
||||
|
||||
export class FileSystemObject {
|
||||
>FileSystemObject : Symbol(FileSystemObject, Decl(typeGuardOfFormThisMember.ts, 1, 16))
|
||||
|
||||
isFSO: this is FileSystemObject;
|
||||
>isFSO : Symbol(isFSO, Decl(typeGuardOfFormThisMember.ts, 2, 32))
|
||||
>FileSystemObject : Symbol(FileSystemObject, Decl(typeGuardOfFormThisMember.ts, 1, 16))
|
||||
|
||||
get isFile(): this is File {
|
||||
>isFile : Symbol(isFile, Decl(typeGuardOfFormThisMember.ts, 3, 34), Decl(typeGuardOfFormThisMember.ts, 6, 3))
|
||||
>File : Symbol(File, Decl(typeGuardOfFormThisMember.ts, 15, 2))
|
||||
|
||||
return this instanceof File;
|
||||
>this : Symbol(FileSystemObject, Decl(typeGuardOfFormThisMember.ts, 1, 16))
|
||||
>File : Symbol(File, Decl(typeGuardOfFormThisMember.ts, 15, 2))
|
||||
}
|
||||
set isFile(param) {
|
||||
>isFile : Symbol(isFile, Decl(typeGuardOfFormThisMember.ts, 3, 34), Decl(typeGuardOfFormThisMember.ts, 6, 3))
|
||||
>param : Symbol(param, Decl(typeGuardOfFormThisMember.ts, 7, 13))
|
||||
|
||||
// noop
|
||||
}
|
||||
get isDirectory(): this is Directory {
|
||||
>isDirectory : Symbol(isDirectory, Decl(typeGuardOfFormThisMember.ts, 9, 3))
|
||||
>Directory : Symbol(Directory, Decl(typeGuardOfFormThisMember.ts, 19, 2))
|
||||
|
||||
return this instanceof Directory;
|
||||
>this : Symbol(FileSystemObject, Decl(typeGuardOfFormThisMember.ts, 1, 16))
|
||||
>Directory : Symbol(Directory, Decl(typeGuardOfFormThisMember.ts, 19, 2))
|
||||
}
|
||||
isNetworked: this is (Networked & this);
|
||||
>isNetworked : Symbol(isNetworked, Decl(typeGuardOfFormThisMember.ts, 12, 3))
|
||||
>Networked : Symbol(Networked, Decl(typeGuardOfFormThisMember.ts, 22, 2))
|
||||
|
||||
constructor(public path: string) {}
|
||||
>path : Symbol(path, Decl(typeGuardOfFormThisMember.ts, 14, 14))
|
||||
}
|
||||
|
||||
export class File extends FileSystemObject {
|
||||
>File : Symbol(File, Decl(typeGuardOfFormThisMember.ts, 15, 2))
|
||||
>FileSystemObject : Symbol(FileSystemObject, Decl(typeGuardOfFormThisMember.ts, 1, 16))
|
||||
|
||||
constructor(path: string, public content: string) { super(path); }
|
||||
>path : Symbol(path, Decl(typeGuardOfFormThisMember.ts, 18, 14))
|
||||
>content : Symbol(content, Decl(typeGuardOfFormThisMember.ts, 18, 27))
|
||||
>super : Symbol(FileSystemObject, Decl(typeGuardOfFormThisMember.ts, 1, 16))
|
||||
>path : Symbol(path, Decl(typeGuardOfFormThisMember.ts, 18, 14))
|
||||
}
|
||||
export class Directory extends FileSystemObject {
|
||||
>Directory : Symbol(Directory, Decl(typeGuardOfFormThisMember.ts, 19, 2))
|
||||
>FileSystemObject : Symbol(FileSystemObject, Decl(typeGuardOfFormThisMember.ts, 1, 16))
|
||||
|
||||
children: FileSystemObject[];
|
||||
>children : Symbol(children, Decl(typeGuardOfFormThisMember.ts, 20, 50))
|
||||
>FileSystemObject : Symbol(FileSystemObject, Decl(typeGuardOfFormThisMember.ts, 1, 16))
|
||||
}
|
||||
export interface Networked {
|
||||
>Networked : Symbol(Networked, Decl(typeGuardOfFormThisMember.ts, 22, 2))
|
||||
|
||||
host: string;
|
||||
>host : Symbol(host, Decl(typeGuardOfFormThisMember.ts, 23, 29))
|
||||
}
|
||||
|
||||
let file: FileSystemObject = new File("foo/bar.txt", "foo");
|
||||
>file : Symbol(file, Decl(typeGuardOfFormThisMember.ts, 27, 4))
|
||||
>FileSystemObject : Symbol(FileSystemObject, Decl(typeGuardOfFormThisMember.ts, 1, 16))
|
||||
>File : Symbol(File, Decl(typeGuardOfFormThisMember.ts, 15, 2))
|
||||
|
||||
file.isNetworked = false;
|
||||
>file.isNetworked : Symbol(FileSystemObject.isNetworked, Decl(typeGuardOfFormThisMember.ts, 12, 3))
|
||||
>file : Symbol(file, Decl(typeGuardOfFormThisMember.ts, 27, 4))
|
||||
>isNetworked : Symbol(FileSystemObject.isNetworked, Decl(typeGuardOfFormThisMember.ts, 12, 3))
|
||||
|
||||
file.isFSO = file.isFile;
|
||||
>file.isFSO : Symbol(FileSystemObject.isFSO, Decl(typeGuardOfFormThisMember.ts, 2, 32))
|
||||
>file : Symbol(file, Decl(typeGuardOfFormThisMember.ts, 27, 4))
|
||||
>isFSO : Symbol(FileSystemObject.isFSO, Decl(typeGuardOfFormThisMember.ts, 2, 32))
|
||||
>file.isFile : Symbol(FileSystemObject.isFile, Decl(typeGuardOfFormThisMember.ts, 3, 34), Decl(typeGuardOfFormThisMember.ts, 6, 3))
|
||||
>file : Symbol(file, Decl(typeGuardOfFormThisMember.ts, 27, 4))
|
||||
>isFile : Symbol(FileSystemObject.isFile, Decl(typeGuardOfFormThisMember.ts, 3, 34), Decl(typeGuardOfFormThisMember.ts, 6, 3))
|
||||
|
||||
file.isFile = true;
|
||||
>file.isFile : Symbol(FileSystemObject.isFile, Decl(typeGuardOfFormThisMember.ts, 3, 34), Decl(typeGuardOfFormThisMember.ts, 6, 3))
|
||||
>file : Symbol(file, Decl(typeGuardOfFormThisMember.ts, 27, 4))
|
||||
>isFile : Symbol(FileSystemObject.isFile, Decl(typeGuardOfFormThisMember.ts, 3, 34), Decl(typeGuardOfFormThisMember.ts, 6, 3))
|
||||
|
||||
let x = file.isFile;
|
||||
>x : Symbol(x, Decl(typeGuardOfFormThisMember.ts, 31, 4))
|
||||
>file.isFile : Symbol(FileSystemObject.isFile, Decl(typeGuardOfFormThisMember.ts, 3, 34), Decl(typeGuardOfFormThisMember.ts, 6, 3))
|
||||
>file : Symbol(file, Decl(typeGuardOfFormThisMember.ts, 27, 4))
|
||||
>isFile : Symbol(FileSystemObject.isFile, Decl(typeGuardOfFormThisMember.ts, 3, 34), Decl(typeGuardOfFormThisMember.ts, 6, 3))
|
||||
|
||||
if (file.isFile) {
|
||||
>file.isFile : Symbol(FileSystemObject.isFile, Decl(typeGuardOfFormThisMember.ts, 3, 34), Decl(typeGuardOfFormThisMember.ts, 6, 3))
|
||||
>file : Symbol(file, Decl(typeGuardOfFormThisMember.ts, 27, 4))
|
||||
>isFile : Symbol(FileSystemObject.isFile, Decl(typeGuardOfFormThisMember.ts, 3, 34), Decl(typeGuardOfFormThisMember.ts, 6, 3))
|
||||
|
||||
file.content;
|
||||
>file.content : Symbol(File.content, Decl(typeGuardOfFormThisMember.ts, 18, 27))
|
||||
>file : Symbol(file, Decl(typeGuardOfFormThisMember.ts, 27, 4))
|
||||
>content : Symbol(File.content, Decl(typeGuardOfFormThisMember.ts, 18, 27))
|
||||
|
||||
if (file.isNetworked) {
|
||||
>file.isNetworked : Symbol(FileSystemObject.isNetworked, Decl(typeGuardOfFormThisMember.ts, 12, 3))
|
||||
>file : Symbol(file, Decl(typeGuardOfFormThisMember.ts, 27, 4))
|
||||
>isNetworked : Symbol(FileSystemObject.isNetworked, Decl(typeGuardOfFormThisMember.ts, 12, 3))
|
||||
|
||||
file.host;
|
||||
>file.host : Symbol(Networked.host, Decl(typeGuardOfFormThisMember.ts, 23, 29))
|
||||
>file : Symbol(file, Decl(typeGuardOfFormThisMember.ts, 27, 4))
|
||||
>host : Symbol(Networked.host, Decl(typeGuardOfFormThisMember.ts, 23, 29))
|
||||
|
||||
file.content;
|
||||
>file.content : Symbol(File.content, Decl(typeGuardOfFormThisMember.ts, 18, 27))
|
||||
>file : Symbol(file, Decl(typeGuardOfFormThisMember.ts, 27, 4))
|
||||
>content : Symbol(File.content, Decl(typeGuardOfFormThisMember.ts, 18, 27))
|
||||
}
|
||||
}
|
||||
else if (file.isDirectory) {
|
||||
>file.isDirectory : Symbol(FileSystemObject.isDirectory, Decl(typeGuardOfFormThisMember.ts, 9, 3))
|
||||
>file : Symbol(file, Decl(typeGuardOfFormThisMember.ts, 27, 4))
|
||||
>isDirectory : Symbol(FileSystemObject.isDirectory, Decl(typeGuardOfFormThisMember.ts, 9, 3))
|
||||
|
||||
file.children;
|
||||
>file.children : Symbol(Directory.children, Decl(typeGuardOfFormThisMember.ts, 20, 50))
|
||||
>file : Symbol(file, Decl(typeGuardOfFormThisMember.ts, 27, 4))
|
||||
>children : Symbol(Directory.children, Decl(typeGuardOfFormThisMember.ts, 20, 50))
|
||||
}
|
||||
else if (file.isNetworked) {
|
||||
>file.isNetworked : Symbol(FileSystemObject.isNetworked, Decl(typeGuardOfFormThisMember.ts, 12, 3))
|
||||
>file : Symbol(file, Decl(typeGuardOfFormThisMember.ts, 27, 4))
|
||||
>isNetworked : Symbol(FileSystemObject.isNetworked, Decl(typeGuardOfFormThisMember.ts, 12, 3))
|
||||
|
||||
file.host;
|
||||
>file.host : Symbol(Networked.host, Decl(typeGuardOfFormThisMember.ts, 23, 29))
|
||||
>file : Symbol(file, Decl(typeGuardOfFormThisMember.ts, 27, 4))
|
||||
>host : Symbol(Networked.host, Decl(typeGuardOfFormThisMember.ts, 23, 29))
|
||||
}
|
||||
|
||||
interface GenericLeadGuard<T> extends GenericGuard<T> {
|
||||
>GenericLeadGuard : Symbol(GenericLeadGuard, Decl(typeGuardOfFormThisMember.ts, 44, 2))
|
||||
>T : Symbol(T, Decl(typeGuardOfFormThisMember.ts, 46, 28))
|
||||
>GenericGuard : Symbol(GenericGuard, Decl(typeGuardOfFormThisMember.ts, 52, 2))
|
||||
>T : Symbol(T, Decl(typeGuardOfFormThisMember.ts, 46, 28))
|
||||
|
||||
lead(): void;
|
||||
>lead : Symbol(lead, Decl(typeGuardOfFormThisMember.ts, 46, 56))
|
||||
}
|
||||
|
||||
interface GenericFollowerGuard<T> extends GenericGuard<T> {
|
||||
>GenericFollowerGuard : Symbol(GenericFollowerGuard, Decl(typeGuardOfFormThisMember.ts, 48, 2))
|
||||
>T : Symbol(T, Decl(typeGuardOfFormThisMember.ts, 50, 32))
|
||||
>GenericGuard : Symbol(GenericGuard, Decl(typeGuardOfFormThisMember.ts, 52, 2))
|
||||
>T : Symbol(T, Decl(typeGuardOfFormThisMember.ts, 50, 32))
|
||||
|
||||
follow(): void;
|
||||
>follow : Symbol(follow, Decl(typeGuardOfFormThisMember.ts, 50, 60))
|
||||
}
|
||||
|
||||
interface GenericGuard<T> {
|
||||
>GenericGuard : Symbol(GenericGuard, Decl(typeGuardOfFormThisMember.ts, 52, 2))
|
||||
>T : Symbol(T, Decl(typeGuardOfFormThisMember.ts, 54, 24))
|
||||
|
||||
target: T;
|
||||
>target : Symbol(target, Decl(typeGuardOfFormThisMember.ts, 54, 28))
|
||||
>T : Symbol(T, Decl(typeGuardOfFormThisMember.ts, 54, 24))
|
||||
|
||||
isLeader: this is (GenericLeadGuard<T>);
|
||||
>isLeader : Symbol(isLeader, Decl(typeGuardOfFormThisMember.ts, 55, 12))
|
||||
>GenericLeadGuard : Symbol(GenericLeadGuard, Decl(typeGuardOfFormThisMember.ts, 44, 2))
|
||||
>T : Symbol(T, Decl(typeGuardOfFormThisMember.ts, 54, 24))
|
||||
|
||||
isFollower: this is GenericFollowerGuard<T>;
|
||||
>isFollower : Symbol(isFollower, Decl(typeGuardOfFormThisMember.ts, 56, 42))
|
||||
>GenericFollowerGuard : Symbol(GenericFollowerGuard, Decl(typeGuardOfFormThisMember.ts, 48, 2))
|
||||
>T : Symbol(T, Decl(typeGuardOfFormThisMember.ts, 54, 24))
|
||||
}
|
||||
|
||||
let guard: GenericGuard<File>;
|
||||
>guard : Symbol(guard, Decl(typeGuardOfFormThisMember.ts, 60, 4))
|
||||
>GenericGuard : Symbol(GenericGuard, Decl(typeGuardOfFormThisMember.ts, 52, 2))
|
||||
>File : Symbol(File, Decl(typeGuardOfFormThisMember.ts, 15, 2))
|
||||
|
||||
if (guard.isLeader) {
|
||||
>guard.isLeader : Symbol(GenericGuard.isLeader, Decl(typeGuardOfFormThisMember.ts, 55, 12))
|
||||
>guard : Symbol(guard, Decl(typeGuardOfFormThisMember.ts, 60, 4))
|
||||
>isLeader : Symbol(GenericGuard.isLeader, Decl(typeGuardOfFormThisMember.ts, 55, 12))
|
||||
|
||||
guard.lead();
|
||||
>guard.lead : Symbol(GenericLeadGuard.lead, Decl(typeGuardOfFormThisMember.ts, 46, 56))
|
||||
>guard : Symbol(guard, Decl(typeGuardOfFormThisMember.ts, 60, 4))
|
||||
>lead : Symbol(GenericLeadGuard.lead, Decl(typeGuardOfFormThisMember.ts, 46, 56))
|
||||
}
|
||||
else if (guard.isFollower) {
|
||||
>guard.isFollower : Symbol(GenericGuard.isFollower, Decl(typeGuardOfFormThisMember.ts, 56, 42))
|
||||
>guard : Symbol(guard, Decl(typeGuardOfFormThisMember.ts, 60, 4))
|
||||
>isFollower : Symbol(GenericGuard.isFollower, Decl(typeGuardOfFormThisMember.ts, 56, 42))
|
||||
|
||||
guard.follow();
|
||||
>guard.follow : Symbol(GenericFollowerGuard.follow, Decl(typeGuardOfFormThisMember.ts, 50, 60))
|
||||
>guard : Symbol(guard, Decl(typeGuardOfFormThisMember.ts, 60, 4))
|
||||
>follow : Symbol(GenericFollowerGuard.follow, Decl(typeGuardOfFormThisMember.ts, 50, 60))
|
||||
}
|
||||
|
||||
interface SpecificGuard {
|
||||
>SpecificGuard : Symbol(SpecificGuard, Decl(typeGuardOfFormThisMember.ts, 66, 2))
|
||||
|
||||
isMoreSpecific: this is MoreSpecificGuard;
|
||||
>isMoreSpecific : Symbol(isMoreSpecific, Decl(typeGuardOfFormThisMember.ts, 68, 26))
|
||||
>MoreSpecificGuard : Symbol(MoreSpecificGuard, Decl(typeGuardOfFormThisMember.ts, 70, 2))
|
||||
}
|
||||
|
||||
interface MoreSpecificGuard extends SpecificGuard {
|
||||
>MoreSpecificGuard : Symbol(MoreSpecificGuard, Decl(typeGuardOfFormThisMember.ts, 70, 2))
|
||||
>SpecificGuard : Symbol(SpecificGuard, Decl(typeGuardOfFormThisMember.ts, 66, 2))
|
||||
|
||||
do(): void;
|
||||
>do : Symbol(do, Decl(typeGuardOfFormThisMember.ts, 72, 52))
|
||||
}
|
||||
|
||||
let general: SpecificGuard;
|
||||
>general : Symbol(general, Decl(typeGuardOfFormThisMember.ts, 76, 4))
|
||||
>SpecificGuard : Symbol(SpecificGuard, Decl(typeGuardOfFormThisMember.ts, 66, 2))
|
||||
|
||||
if (general.isMoreSpecific) {
|
||||
>general.isMoreSpecific : Symbol(SpecificGuard.isMoreSpecific, Decl(typeGuardOfFormThisMember.ts, 68, 26))
|
||||
>general : Symbol(general, Decl(typeGuardOfFormThisMember.ts, 76, 4))
|
||||
>isMoreSpecific : Symbol(SpecificGuard.isMoreSpecific, Decl(typeGuardOfFormThisMember.ts, 68, 26))
|
||||
|
||||
general.do();
|
||||
>general.do : Symbol(MoreSpecificGuard.do, Decl(typeGuardOfFormThisMember.ts, 72, 52))
|
||||
>general : Symbol(general, Decl(typeGuardOfFormThisMember.ts, 76, 4))
|
||||
>do : Symbol(MoreSpecificGuard.do, Decl(typeGuardOfFormThisMember.ts, 72, 52))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,254 +0,0 @@
|
||||
=== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMember.ts ===
|
||||
// There's a 'File' class in the stdlib, wrap with a namespace to avoid collision
|
||||
namespace Test {
|
||||
>Test : typeof Test
|
||||
|
||||
export class FileSystemObject {
|
||||
>FileSystemObject : FileSystemObject
|
||||
|
||||
isFSO: this is FileSystemObject;
|
||||
>isFSO : this is FileSystemObject
|
||||
>FileSystemObject : FileSystemObject
|
||||
|
||||
get isFile(): this is File {
|
||||
>isFile : this is File
|
||||
>File : File
|
||||
|
||||
return this instanceof File;
|
||||
>this instanceof File : boolean
|
||||
>this : this
|
||||
>File : typeof File
|
||||
}
|
||||
set isFile(param) {
|
||||
>isFile : this is File
|
||||
>param : boolean
|
||||
|
||||
// noop
|
||||
}
|
||||
get isDirectory(): this is Directory {
|
||||
>isDirectory : this is Directory
|
||||
>Directory : Directory
|
||||
|
||||
return this instanceof Directory;
|
||||
>this instanceof Directory : boolean
|
||||
>this : this
|
||||
>Directory : typeof Directory
|
||||
}
|
||||
isNetworked: this is (Networked & this);
|
||||
>isNetworked : this is Networked & this
|
||||
>Networked : Networked
|
||||
|
||||
constructor(public path: string) {}
|
||||
>path : string
|
||||
}
|
||||
|
||||
export class File extends FileSystemObject {
|
||||
>File : File
|
||||
>FileSystemObject : FileSystemObject
|
||||
|
||||
constructor(path: string, public content: string) { super(path); }
|
||||
>path : string
|
||||
>content : string
|
||||
>super(path) : void
|
||||
>super : typeof FileSystemObject
|
||||
>path : string
|
||||
}
|
||||
export class Directory extends FileSystemObject {
|
||||
>Directory : Directory
|
||||
>FileSystemObject : FileSystemObject
|
||||
|
||||
children: FileSystemObject[];
|
||||
>children : FileSystemObject[]
|
||||
>FileSystemObject : FileSystemObject
|
||||
}
|
||||
export interface Networked {
|
||||
>Networked : Networked
|
||||
|
||||
host: string;
|
||||
>host : string
|
||||
}
|
||||
|
||||
let file: FileSystemObject = new File("foo/bar.txt", "foo");
|
||||
>file : FileSystemObject
|
||||
>FileSystemObject : FileSystemObject
|
||||
>new File("foo/bar.txt", "foo") : File
|
||||
>File : typeof File
|
||||
>"foo/bar.txt" : string
|
||||
>"foo" : string
|
||||
|
||||
file.isNetworked = false;
|
||||
>file.isNetworked = false : boolean
|
||||
>file.isNetworked : this is Networked & FileSystemObject
|
||||
>file : FileSystemObject
|
||||
>isNetworked : this is Networked & FileSystemObject
|
||||
>false : boolean
|
||||
|
||||
file.isFSO = file.isFile;
|
||||
>file.isFSO = file.isFile : this is File
|
||||
>file.isFSO : this is FileSystemObject
|
||||
>file : FileSystemObject
|
||||
>isFSO : this is FileSystemObject
|
||||
>file.isFile : this is File
|
||||
>file : FileSystemObject
|
||||
>isFile : this is File
|
||||
|
||||
file.isFile = true;
|
||||
>file.isFile = true : boolean
|
||||
>file.isFile : this is File
|
||||
>file : FileSystemObject
|
||||
>isFile : this is File
|
||||
>true : boolean
|
||||
|
||||
let x = file.isFile;
|
||||
>x : boolean
|
||||
>file.isFile : this is File
|
||||
>file : FileSystemObject
|
||||
>isFile : this is File
|
||||
|
||||
if (file.isFile) {
|
||||
>file.isFile : this is File
|
||||
>file : FileSystemObject
|
||||
>isFile : this is File
|
||||
|
||||
file.content;
|
||||
>file.content : string
|
||||
>file : File
|
||||
>content : string
|
||||
|
||||
if (file.isNetworked) {
|
||||
>file.isNetworked : this is Networked & File
|
||||
>file : File
|
||||
>isNetworked : this is Networked & File
|
||||
|
||||
file.host;
|
||||
>file.host : string
|
||||
>file : Networked & File
|
||||
>host : string
|
||||
|
||||
file.content;
|
||||
>file.content : string
|
||||
>file : Networked & File
|
||||
>content : string
|
||||
}
|
||||
}
|
||||
else if (file.isDirectory) {
|
||||
>file.isDirectory : this is Directory
|
||||
>file : FileSystemObject
|
||||
>isDirectory : this is Directory
|
||||
|
||||
file.children;
|
||||
>file.children : FileSystemObject[]
|
||||
>file : Directory
|
||||
>children : FileSystemObject[]
|
||||
}
|
||||
else if (file.isNetworked) {
|
||||
>file.isNetworked : this is Networked & FileSystemObject
|
||||
>file : FileSystemObject
|
||||
>isNetworked : this is Networked & FileSystemObject
|
||||
|
||||
file.host;
|
||||
>file.host : string
|
||||
>file : Networked & FileSystemObject
|
||||
>host : string
|
||||
}
|
||||
|
||||
interface GenericLeadGuard<T> extends GenericGuard<T> {
|
||||
>GenericLeadGuard : GenericLeadGuard<T>
|
||||
>T : T
|
||||
>GenericGuard : GenericGuard<T>
|
||||
>T : T
|
||||
|
||||
lead(): void;
|
||||
>lead : () => void
|
||||
}
|
||||
|
||||
interface GenericFollowerGuard<T> extends GenericGuard<T> {
|
||||
>GenericFollowerGuard : GenericFollowerGuard<T>
|
||||
>T : T
|
||||
>GenericGuard : GenericGuard<T>
|
||||
>T : T
|
||||
|
||||
follow(): void;
|
||||
>follow : () => void
|
||||
}
|
||||
|
||||
interface GenericGuard<T> {
|
||||
>GenericGuard : GenericGuard<T>
|
||||
>T : T
|
||||
|
||||
target: T;
|
||||
>target : T
|
||||
>T : T
|
||||
|
||||
isLeader: this is (GenericLeadGuard<T>);
|
||||
>isLeader : this is GenericLeadGuard<T>
|
||||
>GenericLeadGuard : GenericLeadGuard<T>
|
||||
>T : T
|
||||
|
||||
isFollower: this is GenericFollowerGuard<T>;
|
||||
>isFollower : this is GenericFollowerGuard<T>
|
||||
>GenericFollowerGuard : GenericFollowerGuard<T>
|
||||
>T : T
|
||||
}
|
||||
|
||||
let guard: GenericGuard<File>;
|
||||
>guard : GenericGuard<File>
|
||||
>GenericGuard : GenericGuard<T>
|
||||
>File : File
|
||||
|
||||
if (guard.isLeader) {
|
||||
>guard.isLeader : this is GenericLeadGuard<File>
|
||||
>guard : GenericGuard<File>
|
||||
>isLeader : this is GenericLeadGuard<File>
|
||||
|
||||
guard.lead();
|
||||
>guard.lead() : void
|
||||
>guard.lead : () => void
|
||||
>guard : GenericLeadGuard<File>
|
||||
>lead : () => void
|
||||
}
|
||||
else if (guard.isFollower) {
|
||||
>guard.isFollower : this is GenericFollowerGuard<File>
|
||||
>guard : GenericGuard<File>
|
||||
>isFollower : this is GenericFollowerGuard<File>
|
||||
|
||||
guard.follow();
|
||||
>guard.follow() : void
|
||||
>guard.follow : () => void
|
||||
>guard : GenericFollowerGuard<File>
|
||||
>follow : () => void
|
||||
}
|
||||
|
||||
interface SpecificGuard {
|
||||
>SpecificGuard : SpecificGuard
|
||||
|
||||
isMoreSpecific: this is MoreSpecificGuard;
|
||||
>isMoreSpecific : this is MoreSpecificGuard
|
||||
>MoreSpecificGuard : MoreSpecificGuard
|
||||
}
|
||||
|
||||
interface MoreSpecificGuard extends SpecificGuard {
|
||||
>MoreSpecificGuard : MoreSpecificGuard
|
||||
>SpecificGuard : SpecificGuard
|
||||
|
||||
do(): void;
|
||||
>do : () => void
|
||||
}
|
||||
|
||||
let general: SpecificGuard;
|
||||
>general : SpecificGuard
|
||||
>SpecificGuard : SpecificGuard
|
||||
|
||||
if (general.isMoreSpecific) {
|
||||
>general.isMoreSpecific : this is MoreSpecificGuard
|
||||
>general : SpecificGuard
|
||||
>isMoreSpecific : this is MoreSpecificGuard
|
||||
|
||||
general.do();
|
||||
>general.do() : void
|
||||
>general.do : () => void
|
||||
>general : MoreSpecificGuard
|
||||
>do : () => void
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,32 @@
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMemberErrors.ts(29,2): error TS1226: Type predicate 'this is File' is not assignable to 'this is Networked & FileSystemObject'.
|
||||
Type 'File' is not assignable to type 'Networked & FileSystemObject'.
|
||||
Type 'File' is not assignable to type 'Networked'.
|
||||
Property 'host' is missing in type 'File'.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMemberErrors.ts(31,2): error TS1226: Type predicate 'this is FileSystemObject' is not assignable to 'this is File'.
|
||||
Type 'FileSystemObject' is not assignable to type 'File'.
|
||||
Property 'content' is missing in type 'FileSystemObject'.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMemberErrors.ts(4,10): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMemberErrors.ts(5,17): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMemberErrors.ts(11,22): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMemberErrors.ts(14,16): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMemberErrors.ts (2 errors) ====
|
||||
==== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMemberErrors.ts (4 errors) ====
|
||||
// There's a 'File' class in the stdlib, wrap with a namespace to avoid collision
|
||||
namespace Test {
|
||||
export class FileSystemObject {
|
||||
isFSO: this is FileSystemObject;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
get isFile(): this is File {
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
return this instanceof File;
|
||||
}
|
||||
set isFile(param) {
|
||||
// noop
|
||||
}
|
||||
get isDirectory(): this is Directory {
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
return this instanceof Directory;
|
||||
}
|
||||
isNetworked: this is (Networked & this);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
constructor(public path: string) {}
|
||||
}
|
||||
|
||||
@@ -37,15 +42,6 @@ tests/cases/conformance/expressions/typeGuards/typeGuardOfFormThisMemberErrors.t
|
||||
|
||||
let file: FileSystemObject = new File("foo/bar.txt", "foo");
|
||||
file.isNetworked = file.isFile;
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS1226: Type predicate 'this is File' is not assignable to 'this is Networked & FileSystemObject'.
|
||||
!!! error TS1226: Type 'File' is not assignable to type 'Networked & FileSystemObject'.
|
||||
!!! error TS1226: Type 'File' is not assignable to type 'Networked'.
|
||||
!!! error TS1226: Property 'host' is missing in type 'File'.
|
||||
file.isFSO = file.isNetworked;
|
||||
file.isFile = file.isFSO;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1226: Type predicate 'this is FileSystemObject' is not assignable to 'this is File'.
|
||||
!!! error TS1226: Type 'FileSystemObject' is not assignable to type 'File'.
|
||||
!!! error TS1226: Property 'content' is missing in type 'FileSystemObject'.
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration01.ts(2,8): error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration01.ts (1 errors) ====
|
||||
|
||||
var x: this is string;
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS1228: A type predicate is only allowed in return type position for functions and methods.
|
||||
@@ -0,0 +1,10 @@
|
||||
//// [typePredicateOnVariableDeclaration01.ts]
|
||||
|
||||
var x: this is string;
|
||||
|
||||
//// [typePredicateOnVariableDeclaration01.js]
|
||||
var x;
|
||||
|
||||
|
||||
//// [typePredicateOnVariableDeclaration01.d.ts]
|
||||
declare var x: this is string;
|
||||
@@ -0,0 +1,20 @@
|
||||
tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration02.ts(2,8): error TS2304: Cannot find name 'z'.
|
||||
tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration02.ts(2,8): error TS4025: Exported variable 'y' has or is using private name 'z'.
|
||||
tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration02.ts(2,10): error TS1005: '=' expected.
|
||||
tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration02.ts(2,10): error TS2304: Cannot find name 'is'.
|
||||
tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration02.ts(2,13): error TS1005: ',' expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration02.ts (5 errors) ====
|
||||
|
||||
var y: z is number;
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'z'.
|
||||
~
|
||||
!!! error TS4025: Exported variable 'y' has or is using private name 'z'.
|
||||
~~
|
||||
!!! error TS1005: '=' expected.
|
||||
~~
|
||||
!!! error TS2304: Cannot find name 'is'.
|
||||
~~~~~~
|
||||
!!! error TS1005: ',' expected.
|
||||
@@ -0,0 +1,6 @@
|
||||
//// [typePredicateOnVariableDeclaration02.ts]
|
||||
|
||||
var y: z is number;
|
||||
|
||||
//// [typePredicateOnVariableDeclaration02.js]
|
||||
var y = is, number;
|
||||
@@ -110,7 +110,7 @@ function foo1<a>(value: void|a): void {
|
||||
>a : a
|
||||
|
||||
if (isVoid(value)) {
|
||||
>isVoid(value) : value is void
|
||||
>isVoid(value) : boolean
|
||||
>isVoid : <a>(value: void | a) => value is void
|
||||
>value : void | a
|
||||
|
||||
@@ -130,7 +130,7 @@ function baz1<a>(value: void|a): void {
|
||||
>a : a
|
||||
|
||||
if (isNonVoid(value)) {
|
||||
>isNonVoid(value) : value is a
|
||||
>isNonVoid(value) : boolean
|
||||
>isNonVoid : <a>(value: void | a) => value is a
|
||||
>value : void | a
|
||||
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// @declaration: true
|
||||
// @module: commonjs
|
||||
|
||||
export function f(x: any): x is number {
|
||||
return typeof x === "number";
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// @declaration: true
|
||||
// @module: commonjs
|
||||
|
||||
interface I {
|
||||
a: number;
|
||||
}
|
||||
|
||||
export function f(x: any): x is I {
|
||||
return typeof x.a === "number";
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// @declaration: true
|
||||
// @module: commonjs
|
||||
|
||||
export class C {
|
||||
m(): this is D {
|
||||
return this instanceof D;
|
||||
}
|
||||
}
|
||||
|
||||
export class D extends C {
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// @declaration: true
|
||||
// @module: commonjs
|
||||
|
||||
export interface Foo {
|
||||
a: string;
|
||||
b: number;
|
||||
c: boolean;
|
||||
}
|
||||
|
||||
export const obj = {
|
||||
m(): this is Foo {
|
||||
let dis = this as Foo;
|
||||
return dis.a != null && dis.b != null && dis.c != null;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// @declaration: true
|
||||
// @module: commonjs
|
||||
|
||||
export class C {
|
||||
m(): this is D {
|
||||
return this instanceof D;
|
||||
}
|
||||
}
|
||||
|
||||
class D extends C {
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// @declaration: true
|
||||
// @module: commonjs
|
||||
|
||||
interface Foo {
|
||||
a: string;
|
||||
b: number;
|
||||
c: boolean;
|
||||
}
|
||||
|
||||
export const obj = {
|
||||
m(): this is Foo {
|
||||
let dis = this as Foo;
|
||||
return dis.a != null && dis.b != null && dis.c != null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
declare function isString1(a: number, b: Object): b is string;
|
||||
|
||||
declare function isString2(a: Object): a is string;
|
||||
|
||||
switch (isString1(0, "")) {
|
||||
case isString2(""):
|
||||
default:
|
||||
}
|
||||
|
||||
var x = isString1(0, "") === isString2("");
|
||||
|
||||
function isString3(a: number, b: number, c: Object): c is string {
|
||||
return isString1(0, c);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
// @declaration: true
|
||||
|
||||
var x: this is string;
|
||||
@@ -0,0 +1,3 @@
|
||||
// @declaration: true
|
||||
|
||||
var y: z is number;
|
||||
@@ -0,0 +1,52 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// class FileSystemObject {
|
||||
//// isFile(): this is Item {
|
||||
//// return this instanceof Item;
|
||||
//// }
|
||||
//// isDirectory(): this is Directory {
|
||||
//// return this instanceof Directory;
|
||||
//// }
|
||||
//// isNetworked(): this is (Networked & this) {
|
||||
//// return !!(this as Networked).host;
|
||||
//// }
|
||||
//// constructor(public path: string) {}
|
||||
//// }
|
||||
////
|
||||
//// class Item extends FileSystemObject {
|
||||
//// constructor(path: string, public content: string) { super(path); }
|
||||
//// }
|
||||
//// class Directory extends FileSystemObject {
|
||||
//// children: FileSystemObject[];
|
||||
//// }
|
||||
//// interface Networked {
|
||||
//// host: string;
|
||||
//// }
|
||||
////
|
||||
//// const obj: FileSystemObject = new Item("/foo", "");
|
||||
//// if (obj.isFile()) {
|
||||
//// obj./*1*/;
|
||||
//// if (obj.isNetworked()) {
|
||||
//// obj./*2*/;
|
||||
//// }
|
||||
//// }
|
||||
//// if (obj.isDirectory()) {
|
||||
//// obj./*3*/;
|
||||
//// if (obj.isNetworked()) {
|
||||
//// obj./*4*/;
|
||||
//// }
|
||||
//// }
|
||||
//// if (obj.isNetworked()) {
|
||||
//// obj./*5*/;
|
||||
//// }
|
||||
|
||||
goTo.marker("1");
|
||||
verify.completionListContains("content");
|
||||
goTo.marker("2");
|
||||
verify.completionListContains("host");
|
||||
goTo.marker("3");
|
||||
verify.completionListContains("children");
|
||||
goTo.marker("4");
|
||||
verify.completionListContains("host");
|
||||
goTo.marker("5");
|
||||
verify.completionListContains("host");
|
||||
@@ -0,0 +1,43 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// interface Sundries {
|
||||
//// broken: boolean;
|
||||
//// }
|
||||
////
|
||||
//// interface Supplies {
|
||||
//// spoiled: boolean;
|
||||
//// }
|
||||
////
|
||||
//// interface Crate<T> {
|
||||
//// contents: T;
|
||||
//// isSundries(): this is Crate<Sundries>;
|
||||
//// isSupplies(): this is Crate<Supplies>;
|
||||
//// isPackedTight(): this is (this & {extraContents: T});
|
||||
//// }
|
||||
//// const crate: Crate<any>;
|
||||
//// if (crate.isPackedTight()) {
|
||||
//// crate./*1*/;
|
||||
//// }
|
||||
//// if (crate.isSundries()) {
|
||||
//// crate.contents./*2*/;
|
||||
//// if (crate.isPackedTight()) {
|
||||
//// crate./*3*/;
|
||||
//// }
|
||||
//// }
|
||||
//// if (crate.isSupplies()) {
|
||||
//// crate.contents./*4*/;
|
||||
//// if (crate.isPackedTight()) {
|
||||
//// crate./*5*/;
|
||||
//// }
|
||||
//// }
|
||||
|
||||
goTo.marker("1");
|
||||
verify.completionListContains("extraContents");
|
||||
goTo.marker("2");
|
||||
verify.completionListContains("broken");
|
||||
goTo.marker("3");
|
||||
verify.completionListContains("extraContents");
|
||||
goTo.marker("4");
|
||||
verify.completionListContains("spoiled");
|
||||
goTo.marker("5");
|
||||
verify.completionListContains("extraContents");
|
||||
@@ -0,0 +1,59 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// class FileSystemObject {
|
||||
//// /*1*/isFile(): this is Item {
|
||||
//// return this instanceof Item;
|
||||
//// }
|
||||
//// /*2*/isDirectory(): this is Directory {
|
||||
//// return this instanceof Directory;
|
||||
//// }
|
||||
//// /*3*/isNetworked(): this is (Networked & this) {
|
||||
//// return !!(this as Networked).host;
|
||||
//// }
|
||||
//// constructor(public path: string) {}
|
||||
//// }
|
||||
////
|
||||
//// class Item extends FileSystemObject {
|
||||
//// constructor(path: string, public content: string) { super(path); }
|
||||
//// }
|
||||
//// class Directory extends FileSystemObject {
|
||||
//// children: FileSystemObject[];
|
||||
//// }
|
||||
//// interface Networked {
|
||||
//// host: string;
|
||||
//// }
|
||||
////
|
||||
//// const obj: FileSystemObject = new Item("/foo", "");
|
||||
//// if (obj.isFile/*4*/()) {
|
||||
//// obj.;
|
||||
//// if (obj.isNetworked/*5*/()) {
|
||||
//// obj.;
|
||||
//// }
|
||||
//// }
|
||||
//// if (obj.isDirectory/*6*/()) {
|
||||
//// obj.;
|
||||
//// if (obj.isNetworked/*7*/()) {
|
||||
//// obj.;
|
||||
//// }
|
||||
//// }
|
||||
//// if (obj.isNetworked/*8*/()) {
|
||||
//// obj.;
|
||||
//// }
|
||||
|
||||
goTo.marker("1");
|
||||
verify.quickInfoIs("(method) FileSystemObject.isFile(): this is Item");
|
||||
goTo.marker("2");
|
||||
verify.quickInfoIs("(method) FileSystemObject.isDirectory(): this is Directory");
|
||||
goTo.marker("3");
|
||||
verify.quickInfoIs("(method) FileSystemObject.isNetworked(): this is Networked & this");
|
||||
|
||||
goTo.marker("4");
|
||||
verify.quickInfoIs("(method) FileSystemObject.isFile(): this is Item");
|
||||
goTo.marker("5");
|
||||
verify.quickInfoIs("(method) FileSystemObject.isNetworked(): this is Networked & Item");
|
||||
goTo.marker("6");
|
||||
verify.quickInfoIs("(method) FileSystemObject.isDirectory(): this is Directory");
|
||||
goTo.marker("7");
|
||||
verify.quickInfoIs("(method) FileSystemObject.isNetworked(): this is Networked & Directory");
|
||||
goTo.marker("8");
|
||||
verify.quickInfoIs("(method) FileSystemObject.isNetworked(): this is Networked & FileSystemObject");
|
||||
@@ -0,0 +1,57 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// interface Sundries {
|
||||
//// broken: boolean;
|
||||
//// }
|
||||
////
|
||||
//// interface Supplies {
|
||||
//// spoiled: boolean;
|
||||
//// }
|
||||
////
|
||||
//// interface Crate<T> {
|
||||
//// contents: T;
|
||||
//// /*1*/isSundries(): this is Crate<Sundries>;
|
||||
//// /*2*/isSupplies(): this is Crate<Supplies>;
|
||||
//// /*3*/isPackedTight(): this is (this & {extraContents: T});
|
||||
//// }
|
||||
//// const crate: Crate<any>;
|
||||
//// if (crate.isPackedTight/*4*/()) {
|
||||
//// crate.;
|
||||
//// }
|
||||
//// if (crate.isSundries/*5*/()) {
|
||||
//// crate.contents.;
|
||||
//// if (crate.isPackedTight/*6*/()) {
|
||||
//// crate.;
|
||||
//// }
|
||||
//// }
|
||||
//// if (crate.isSupplies/*7*/()) {
|
||||
//// crate.contents.;
|
||||
//// if (crate.isPackedTight/*8*/()) {
|
||||
//// crate.;
|
||||
//// }
|
||||
//// }
|
||||
|
||||
goTo.marker("1");
|
||||
verify.quickInfoIs("(method) Crate<T>.isSundries(): this is Crate<Sundries>");
|
||||
goTo.marker("2");
|
||||
verify.quickInfoIs("(method) Crate<T>.isSupplies(): this is Crate<Supplies>");
|
||||
goTo.marker("3");
|
||||
verify.quickInfoIs(`(method) Crate<T>.isPackedTight(): this is this & {
|
||||
extraContents: T;
|
||||
}`);
|
||||
goTo.marker("4");
|
||||
verify.quickInfoIs(`(method) Crate<any>.isPackedTight(): this is Crate<any> & {
|
||||
extraContents: any;
|
||||
}`);
|
||||
goTo.marker("5");
|
||||
verify.quickInfoIs("(method) Crate<any>.isSundries(): this is Crate<Sundries>");
|
||||
goTo.marker("6");
|
||||
verify.quickInfoIs(`(method) Crate<Sundries>.isPackedTight(): this is Crate<Sundries> & {
|
||||
extraContents: Sundries;
|
||||
}`);
|
||||
goTo.marker("7");
|
||||
verify.quickInfoIs("(method) Crate<any>.isSupplies(): this is Crate<Supplies>");
|
||||
goTo.marker("8");
|
||||
verify.quickInfoIs(`(method) Crate<Supplies>.isPackedTight(): this is Crate<Supplies> & {
|
||||
extraContents: Supplies;
|
||||
}`);
|
||||
@@ -1,95 +0,0 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// class FileSystemObject {
|
||||
//// get is/*1*/File(): this is Item {
|
||||
//// return this instanceof Item;
|
||||
//// }
|
||||
//// set is/*2*/File(param) {
|
||||
//// // noop
|
||||
//// }
|
||||
//// get is/*3*/Directory(): this is Directory {
|
||||
//// return this instanceof Directory;
|
||||
//// }
|
||||
//// is/*4*/Networked: this is (Networked & this);
|
||||
//// constructor(public path: string) {}
|
||||
//// }
|
||||
////
|
||||
//// class Item extends FileSystemObject {
|
||||
//// constructor(path: string, public content: string) { super(path); }
|
||||
//// }
|
||||
//// class Directory extends FileSystemObject {
|
||||
//// children: FileSystemObject[];
|
||||
//// }
|
||||
//// interface Networked {
|
||||
//// host: string;
|
||||
//// }
|
||||
////
|
||||
//// interface Sundries {
|
||||
//// broken: boolean;
|
||||
//// }
|
||||
////
|
||||
//// interface Supplies {
|
||||
//// spoiled: boolean;
|
||||
//// }
|
||||
////
|
||||
//// interface Crate<T> {
|
||||
//// contents: T;
|
||||
//// is/*5*/Sundries: this is Crate<Sundries>;
|
||||
//// is/*6*/Supplies: this is Crate<Supplies>;
|
||||
//// is/*7*/PackedTight: this is (this & {extraContents: T});
|
||||
//// }
|
||||
////
|
||||
//// const obj: FileSystemObject = new Item("/foo", "");
|
||||
//// if (obj.is/*8*/File) {
|
||||
//// obj./*9*/;
|
||||
//// if (obj.is/*10*/Networked) {
|
||||
//// obj./*11*/;
|
||||
//// }
|
||||
//// }
|
||||
//// if (obj.is/*12*/Directory) {
|
||||
//// obj./*13*/;
|
||||
//// if (obj.is/*14*/Networked) {
|
||||
//// obj./*15*/;
|
||||
//// }
|
||||
//// }
|
||||
//// if (obj.is/*16*/Networked) {
|
||||
//// obj./*17*/;
|
||||
//// }
|
||||
////
|
||||
//// const crate: Crate<any>;
|
||||
//// if (crate.is/*18*/PackedTight) {
|
||||
//// crate./*19*/;
|
||||
//// }
|
||||
//// if (crate.is/*20*/Sundries) {
|
||||
//// crate.contents./*21*/;
|
||||
//// if (crate.is/*22*/PackedTight) {
|
||||
//// crate./*23*/
|
||||
//// }
|
||||
//// }
|
||||
//// if (crate.is/*24*/Supplies) {
|
||||
//// crate.contents./*25*/;
|
||||
//// if (crate.is/*26*/PackedTight) {
|
||||
//// crate./*27*/
|
||||
//// }
|
||||
//// }
|
||||
|
||||
goTo.marker("9");
|
||||
verify.completionListContains("content");
|
||||
goTo.marker("11");
|
||||
verify.completionListContains("host");
|
||||
goTo.marker("13");
|
||||
verify.completionListContains("children");
|
||||
goTo.marker("15");
|
||||
verify.completionListContains("host");
|
||||
goTo.marker("17");
|
||||
verify.completionListContains("host");
|
||||
goTo.marker("19");
|
||||
verify.completionListContains("extraContents");
|
||||
goTo.marker("21");
|
||||
verify.completionListContains("broken");
|
||||
goTo.marker("23");
|
||||
verify.completionListContains("extraContents");
|
||||
goTo.marker("25");
|
||||
verify.completionListContains("spoiled");
|
||||
goTo.marker("27");
|
||||
verify.completionListContains("extraContents");
|
||||
@@ -1,117 +0,0 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// class FileSystemObject {
|
||||
//// get is/*1*/File(): this is Item {
|
||||
//// return this instanceof Item;
|
||||
//// }
|
||||
//// set is/*2*/File(param) {
|
||||
//// // noop
|
||||
//// }
|
||||
//// get is/*3*/Directory(): this is Directory {
|
||||
//// return this instanceof Directory;
|
||||
//// }
|
||||
//// is/*4*/Networked: this is (Networked & this);
|
||||
//// constructor(public path: string) {}
|
||||
//// }
|
||||
////
|
||||
//// class Item extends FileSystemObject {
|
||||
//// constructor(path: string, public content: string) { super(path); }
|
||||
//// }
|
||||
//// class Directory extends FileSystemObject {
|
||||
//// children: FileSystemObject[];
|
||||
//// }
|
||||
//// interface Networked {
|
||||
//// host: string;
|
||||
//// }
|
||||
////
|
||||
//// interface Sundries {
|
||||
//// broken: boolean;
|
||||
//// }
|
||||
////
|
||||
//// interface Supplies {
|
||||
//// spoiled: boolean;
|
||||
//// }
|
||||
////
|
||||
//// interface Crate<T> {
|
||||
//// contents: T;
|
||||
//// is/*5*/Sundries: this is Crate<Sundries>;
|
||||
//// is/*6*/Supplies: this is Crate<Supplies>;
|
||||
//// is/*7*/PackedTight: this is (this & {extraContents: T});
|
||||
//// }
|
||||
////
|
||||
//// const obj: FileSystemObject = new Item("/foo", "");
|
||||
//// if (obj.is/*8*/File) {
|
||||
//// obj./*9*/;
|
||||
//// if (obj.is/*10*/Networked) {
|
||||
//// obj./*11*/;
|
||||
//// }
|
||||
//// }
|
||||
//// if (obj.is/*12*/Directory) {
|
||||
//// obj./*13*/;
|
||||
//// if (obj.is/*14*/Networked) {
|
||||
//// obj./*15*/;
|
||||
//// }
|
||||
//// }
|
||||
//// if (obj.is/*16*/Networked) {
|
||||
//// obj./*17*/;
|
||||
//// }
|
||||
////
|
||||
//// const crate: Crate<any>;
|
||||
//// if (crate.is/*18*/PackedTight) {
|
||||
//// crate./*19*/;
|
||||
//// }
|
||||
//// if (crate.is/*20*/Sundries) {
|
||||
//// crate.contents./*21*/;
|
||||
//// if (crate.is/*22*/PackedTight) {
|
||||
//// crate./*23*/
|
||||
//// }
|
||||
//// }
|
||||
//// if (crate.is/*24*/Supplies) {
|
||||
//// crate.contents./*25*/;
|
||||
//// if (crate.is/*26*/PackedTight) {
|
||||
//// crate./*27*/
|
||||
//// }
|
||||
//// }
|
||||
|
||||
goTo.marker("1");
|
||||
verify.quickInfoIs("(property) FileSystemObject.isFile: this is Item");
|
||||
goTo.marker("2");
|
||||
verify.quickInfoIs("(property) FileSystemObject.isFile: this is Item");
|
||||
goTo.marker("3");
|
||||
verify.quickInfoIs("(property) FileSystemObject.isDirectory: this is Directory");
|
||||
goTo.marker("4");
|
||||
verify.quickInfoIs("(property) FileSystemObject.isNetworked: this is Networked & this");
|
||||
goTo.marker("5");
|
||||
verify.quickInfoIs("(property) Crate<T>.isSundries: this is Crate<Sundries>");
|
||||
goTo.marker("6");
|
||||
verify.quickInfoIs("(property) Crate<T>.isSupplies: this is Crate<Supplies>");
|
||||
goTo.marker("7");
|
||||
verify.quickInfoIs(`(property) Crate<T>.isPackedTight: this is this & {
|
||||
extraContents: T;
|
||||
}`);
|
||||
goTo.marker("8");
|
||||
verify.quickInfoIs("(property) FileSystemObject.isFile: this is Item");
|
||||
goTo.marker("10");
|
||||
verify.quickInfoIs("(property) FileSystemObject.isNetworked: this is Networked & Item");
|
||||
goTo.marker("12");
|
||||
verify.quickInfoIs("(property) FileSystemObject.isDirectory: this is Directory");
|
||||
goTo.marker("14");
|
||||
verify.quickInfoIs("(property) FileSystemObject.isNetworked: this is Networked & Directory");
|
||||
goTo.marker("16");
|
||||
verify.quickInfoIs("(property) FileSystemObject.isNetworked: this is Networked & FileSystemObject");
|
||||
goTo.marker("18");
|
||||
verify.quickInfoIs(`(property) Crate<any>.isPackedTight: this is Crate<any> & {
|
||||
extraContents: any;
|
||||
}`);
|
||||
goTo.marker("20");
|
||||
verify.quickInfoIs("(property) Crate<any>.isSundries: this is Crate<Sundries>");
|
||||
goTo.marker("22");
|
||||
verify.quickInfoIs(`(property) Crate<Sundries>.isPackedTight: this is Crate<Sundries> & {
|
||||
extraContents: Sundries;
|
||||
}`);
|
||||
goTo.marker("24");
|
||||
verify.quickInfoIs("(property) Crate<any>.isSupplies: this is Crate<Supplies>");
|
||||
goTo.marker("26");
|
||||
verify.quickInfoIs(`(property) Crate<Supplies>.isPackedTight: this is Crate<Supplies> & {
|
||||
extraContents: Supplies;
|
||||
}`);
|
||||
Reference in New Issue
Block a user