mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-14 19:16:17 -06:00
Reduce intersections with conflicting privates, elaborate on reasons (#37762)
* Elaborate on reasons for 'never' intersections * Accept new API baselines * Accept new baselines * Add tests * Accept new baselines * Address CR feedback
This commit is contained in:
parent
2187ba1f84
commit
349ae45a2c
@ -4148,7 +4148,9 @@ namespace ts {
|
||||
return undefined!; // TODO: GH#18217
|
||||
}
|
||||
|
||||
type = getReducedType(type);
|
||||
if (!(context.flags & NodeBuilderFlags.NoTypeReduction)) {
|
||||
type = getReducedType(type);
|
||||
}
|
||||
|
||||
if (type.flags & TypeFlags.Any) {
|
||||
context.approximateLength += 3;
|
||||
@ -8460,17 +8462,20 @@ namespace ts {
|
||||
error(baseTypeNode.expression, Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments);
|
||||
return type.resolvedBaseTypes = emptyArray;
|
||||
}
|
||||
baseType = getReducedType(getReturnTypeOfSignature(constructors[0]));
|
||||
baseType = getReturnTypeOfSignature(constructors[0]);
|
||||
}
|
||||
|
||||
if (baseType === errorType) {
|
||||
return type.resolvedBaseTypes = emptyArray;
|
||||
}
|
||||
if (!isValidBaseType(baseType)) {
|
||||
error(baseTypeNode.expression, Diagnostics.Base_constructor_return_type_0_is_not_an_object_type_or_intersection_of_object_types_with_statically_known_members, typeToString(baseType));
|
||||
const reducedBaseType = getReducedType(baseType);
|
||||
if (!isValidBaseType(reducedBaseType)) {
|
||||
const elaboration = elaborateNeverIntersection(/*errorInfo*/ undefined, baseType);
|
||||
const diagnostic = chainDiagnosticMessages(elaboration, Diagnostics.Base_constructor_return_type_0_is_not_an_object_type_or_intersection_of_object_types_with_statically_known_members, typeToString(reducedBaseType));
|
||||
diagnostics.add(createDiagnosticForNodeFromMessageChain(baseTypeNode.expression, diagnostic));
|
||||
return type.resolvedBaseTypes = emptyArray;
|
||||
}
|
||||
if (type === baseType || hasBaseType(baseType, type)) {
|
||||
if (type === reducedBaseType || hasBaseType(reducedBaseType, type)) {
|
||||
error(type.symbol.valueDeclaration, Diagnostics.Type_0_recursively_references_itself_as_a_base_type,
|
||||
typeToString(type, /*enclosingDeclaration*/ undefined, TypeFormatFlags.WriteArrayAsGenericType));
|
||||
return type.resolvedBaseTypes = emptyArray;
|
||||
@ -8482,7 +8487,7 @@ namespace ts {
|
||||
// partial instantiation of the members without the base types fully resolved
|
||||
type.members = undefined;
|
||||
}
|
||||
return type.resolvedBaseTypes = [baseType];
|
||||
return type.resolvedBaseTypes = [reducedBaseType];
|
||||
}
|
||||
|
||||
function areAllOuterTypeParametersApplied(type: Type): boolean { // TODO: GH#18217 Shouldn't this take an InterfaceType?
|
||||
@ -10457,7 +10462,7 @@ namespace ts {
|
||||
else if (type.flags & TypeFlags.Intersection) {
|
||||
if (!((<IntersectionType>type).objectFlags & ObjectFlags.IsNeverIntersectionComputed)) {
|
||||
(<IntersectionType>type).objectFlags |= ObjectFlags.IsNeverIntersectionComputed |
|
||||
(some(getPropertiesOfUnionOrIntersectionType(<IntersectionType>type), isDiscriminantWithNeverType) ? ObjectFlags.IsNeverIntersection : 0);
|
||||
(some(getPropertiesOfUnionOrIntersectionType(<IntersectionType>type), isNeverReducedProperty) ? ObjectFlags.IsNeverIntersection : 0);
|
||||
}
|
||||
return (<IntersectionType>type).objectFlags & ObjectFlags.IsNeverIntersection ? neverType : type;
|
||||
}
|
||||
@ -10476,12 +10481,39 @@ namespace ts {
|
||||
return reduced;
|
||||
}
|
||||
|
||||
function isNeverReducedProperty(prop: Symbol) {
|
||||
return isDiscriminantWithNeverType(prop) || isConflictingPrivateProperty(prop);
|
||||
}
|
||||
|
||||
function isDiscriminantWithNeverType(prop: Symbol) {
|
||||
// Return true for a synthetic non-optional property with non-uniform types, where at least one is
|
||||
// a literal type and none is never, that reduces to never.
|
||||
return !(prop.flags & SymbolFlags.Optional) &&
|
||||
(getCheckFlags(prop) & (CheckFlags.Discriminant | CheckFlags.HasNeverType)) === CheckFlags.Discriminant &&
|
||||
!!(getTypeOfSymbol(prop).flags & TypeFlags.Never);
|
||||
}
|
||||
|
||||
function isConflictingPrivateProperty(prop: Symbol) {
|
||||
// Return true for a synthetic property with multiple declarations, at least one of which is private.
|
||||
return !prop.valueDeclaration && !!(getCheckFlags(prop) & CheckFlags.ContainsPrivate);
|
||||
}
|
||||
|
||||
function elaborateNeverIntersection(errorInfo: DiagnosticMessageChain | undefined, type: Type) {
|
||||
if (getObjectFlags(type) & ObjectFlags.IsNeverIntersection) {
|
||||
const neverProp = find(getPropertiesOfUnionOrIntersectionType(<IntersectionType>type), isDiscriminantWithNeverType);
|
||||
if (neverProp) {
|
||||
return chainDiagnosticMessages(errorInfo, Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents,
|
||||
typeToString(type, /*enclosingDeclaration*/ undefined, TypeFormatFlags.NoTypeReduction), symbolToString(neverProp));
|
||||
}
|
||||
const privateProp = find(getPropertiesOfUnionOrIntersectionType(<IntersectionType>type), isConflictingPrivateProperty);
|
||||
if (privateProp) {
|
||||
return chainDiagnosticMessages(errorInfo, Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some,
|
||||
typeToString(type, /*enclosingDeclaration*/ undefined, TypeFormatFlags.NoTypeReduction), symbolToString(privateProp));
|
||||
}
|
||||
}
|
||||
return errorInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the symbol for the property with the given name in the given type. Creates synthetic union properties when
|
||||
* necessary, maps primitive types and type parameters are to their apparent types, and augments with properties from
|
||||
@ -15609,6 +15641,9 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else {
|
||||
errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
|
||||
}
|
||||
if (!headMessage && maybeSuppress) {
|
||||
lastSkippedInfo = [source, target];
|
||||
// Used by, eg, missing property checking to replace the top-level message with a more informative one
|
||||
@ -16490,14 +16525,7 @@ namespace ts {
|
||||
const sourcePropFlags = getDeclarationModifierFlagsFromSymbol(sourceProp);
|
||||
const targetPropFlags = getDeclarationModifierFlagsFromSymbol(targetProp);
|
||||
if (sourcePropFlags & ModifierFlags.Private || targetPropFlags & ModifierFlags.Private) {
|
||||
const hasDifferingDeclarations = sourceProp.valueDeclaration !== targetProp.valueDeclaration;
|
||||
if (getCheckFlags(sourceProp) & CheckFlags.ContainsPrivate && hasDifferingDeclarations) {
|
||||
if (reportErrors) {
|
||||
reportError(Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(sourceProp), typeToString(source));
|
||||
}
|
||||
return Ternary.False;
|
||||
}
|
||||
if (hasDifferingDeclarations) {
|
||||
if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) {
|
||||
if (reportErrors) {
|
||||
if (sourcePropFlags & ModifierFlags.Private && targetPropFlags & ModifierFlags.Private) {
|
||||
reportError(Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp));
|
||||
@ -23634,12 +23662,6 @@ namespace ts {
|
||||
const flags = getDeclarationModifierFlagsFromSymbol(prop);
|
||||
const errorNode = node.kind === SyntaxKind.QualifiedName ? node.right : node.kind === SyntaxKind.ImportType ? node : node.name;
|
||||
|
||||
if (getCheckFlags(prop) & CheckFlags.ContainsPrivate) {
|
||||
// Synthetic property with private constituent property
|
||||
error(errorNode, Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isSuper) {
|
||||
// TS 1.0 spec (April 2014): 4.8.2
|
||||
// - In a constructor, instance member function, instance member accessor, or
|
||||
@ -24135,7 +24157,7 @@ namespace ts {
|
||||
relatedInfo = suggestion.valueDeclaration && createDiagnosticForNode(suggestion.valueDeclaration, Diagnostics._0_is_declared_here, suggestedName);
|
||||
}
|
||||
else {
|
||||
errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1, declarationNameToString(propNode), typeToString(containingType));
|
||||
errorInfo = chainDiagnosticMessages(elaborateNeverIntersection(errorInfo, containingType), Diagnostics.Property_0_does_not_exist_on_type_1, declarationNameToString(propNode), typeToString(containingType));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2145,10 +2145,6 @@
|
||||
"category": "Error",
|
||||
"code": 2545
|
||||
},
|
||||
"Property '{0}' has conflicting declarations and is inaccessible in type '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 2546
|
||||
},
|
||||
"The type returned by the '{0}()' method of an async iterator must be a promise for a type with a 'value' property.": {
|
||||
"category": "Error",
|
||||
"code": 2547
|
||||
@ -5733,5 +5729,13 @@
|
||||
"An optional chain cannot contain private identifiers.": {
|
||||
"category": "Error",
|
||||
"code": 18030
|
||||
},
|
||||
"The intersection '{0}' was reduced to 'never' because property '{1}' has conflicting types in some constituents.": {
|
||||
"category": "Error",
|
||||
"code": 18031
|
||||
},
|
||||
"The intersection '{0}' was reduced to 'never' because property '{1}' exists in multiple constituents and is private in some.": {
|
||||
"category": "Error",
|
||||
"code": 18032
|
||||
}
|
||||
}
|
||||
|
||||
@ -3685,6 +3685,7 @@ namespace ts {
|
||||
OmitParameterModifiers = 1 << 13, // Omit modifiers on parameters
|
||||
UseAliasDefinedOutsideCurrentScope = 1 << 14, // Allow non-visible aliases
|
||||
UseSingleQuotesForStringLiteralType = 1 << 28, // Use single quotes for string literal type
|
||||
NoTypeReduction = 1 << 29, // Don't call getReducedType
|
||||
|
||||
// Error handling
|
||||
AllowThisInObjectLiteral = 1 << 15,
|
||||
@ -3728,6 +3729,7 @@ namespace ts {
|
||||
|
||||
UseAliasDefinedOutsideCurrentScope = 1 << 14, // For a `type T = ... ` defined in a different file, write `T` instead of its value, even though `T` can't be accessed in the current scope.
|
||||
UseSingleQuotesForStringLiteralType = 1 << 28, // Use single quotes for string literal type
|
||||
NoTypeReduction = 1 << 29, // Don't call getReducedType
|
||||
|
||||
// Error Handling
|
||||
AllowUniqueESSymbolType = 1 << 20, // This is bit 20 to align with the same bit in `NodeBuilderFlags`
|
||||
@ -3747,7 +3749,7 @@ namespace ts {
|
||||
NodeBuilderFlagsMask = NoTruncation | WriteArrayAsGenericType | UseStructuralFallback | WriteTypeArgumentsOfSignature |
|
||||
UseFullyQualifiedType | SuppressAnyReturnType | MultilineObjectLiterals | WriteClassExpressionAsTypeLiteral |
|
||||
UseTypeOfFunction | OmitParameterModifiers | UseAliasDefinedOutsideCurrentScope | AllowUniqueESSymbolType | InTypeAlias |
|
||||
UseSingleQuotesForStringLiteralType,
|
||||
UseSingleQuotesForStringLiteralType | NoTypeReduction,
|
||||
}
|
||||
|
||||
export const enum SymbolFormatFlags {
|
||||
|
||||
@ -2135,6 +2135,7 @@ declare namespace ts {
|
||||
OmitParameterModifiers = 8192,
|
||||
UseAliasDefinedOutsideCurrentScope = 16384,
|
||||
UseSingleQuotesForStringLiteralType = 268435456,
|
||||
NoTypeReduction = 536870912,
|
||||
AllowThisInObjectLiteral = 32768,
|
||||
AllowQualifedNameInPlaceOfIdentifier = 65536,
|
||||
AllowAnonymousIdentifier = 131072,
|
||||
@ -2163,6 +2164,7 @@ declare namespace ts {
|
||||
OmitParameterModifiers = 8192,
|
||||
UseAliasDefinedOutsideCurrentScope = 16384,
|
||||
UseSingleQuotesForStringLiteralType = 268435456,
|
||||
NoTypeReduction = 536870912,
|
||||
AllowUniqueESSymbolType = 1048576,
|
||||
AddUndefined = 131072,
|
||||
WriteArrowStyleSignature = 262144,
|
||||
@ -2171,7 +2173,7 @@ declare namespace ts {
|
||||
InFirstTypeArgument = 4194304,
|
||||
InTypeAlias = 8388608,
|
||||
/** @deprecated */ WriteOwnNameForAnyLike = 0,
|
||||
NodeBuilderFlagsMask = 277904747
|
||||
NodeBuilderFlagsMask = 814775659
|
||||
}
|
||||
export enum SymbolFormatFlags {
|
||||
None = 0,
|
||||
|
||||
@ -2135,6 +2135,7 @@ declare namespace ts {
|
||||
OmitParameterModifiers = 8192,
|
||||
UseAliasDefinedOutsideCurrentScope = 16384,
|
||||
UseSingleQuotesForStringLiteralType = 268435456,
|
||||
NoTypeReduction = 536870912,
|
||||
AllowThisInObjectLiteral = 32768,
|
||||
AllowQualifedNameInPlaceOfIdentifier = 65536,
|
||||
AllowAnonymousIdentifier = 131072,
|
||||
@ -2163,6 +2164,7 @@ declare namespace ts {
|
||||
OmitParameterModifiers = 8192,
|
||||
UseAliasDefinedOutsideCurrentScope = 16384,
|
||||
UseSingleQuotesForStringLiteralType = 268435456,
|
||||
NoTypeReduction = 536870912,
|
||||
AllowUniqueESSymbolType = 1048576,
|
||||
AddUndefined = 131072,
|
||||
WriteArrowStyleSignature = 262144,
|
||||
@ -2171,7 +2173,7 @@ declare namespace ts {
|
||||
InFirstTypeArgument = 4194304,
|
||||
InTypeAlias = 8388608,
|
||||
/** @deprecated */ WriteOwnNameForAnyLike = 0,
|
||||
NodeBuilderFlagsMask = 277904747
|
||||
NodeBuilderFlagsMask = 814775659
|
||||
}
|
||||
export enum SymbolFormatFlags {
|
||||
None = 0,
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
tests/cases/compiler/indexedAccessPrivateMemberOfGenericConstraint.ts(9,24): error TS4105: Private or protected member 'a' cannot be accessed on a type parameter.
|
||||
tests/cases/compiler/indexedAccessPrivateMemberOfGenericConstraint.ts(9,32): error TS4105: Private or protected member 'a' cannot be accessed on a type parameter.
|
||||
tests/cases/compiler/indexedAccessPrivateMemberOfGenericConstraint.ts(10,27): error TS4105: Private or protected member 'a' cannot be accessed on a type parameter.
|
||||
tests/cases/compiler/indexedAccessPrivateMemberOfGenericConstraint.ts(11,27): error TS4105: Private or protected member 'a' cannot be accessed on a type parameter.
|
||||
|
||||
|
||||
==== tests/cases/compiler/indexedAccessPrivateMemberOfGenericConstraint.ts (4 errors) ====
|
||||
==== tests/cases/compiler/indexedAccessPrivateMemberOfGenericConstraint.ts (3 errors) ====
|
||||
class A {
|
||||
private a: number;
|
||||
}
|
||||
@ -22,6 +21,4 @@ tests/cases/compiler/indexedAccessPrivateMemberOfGenericConstraint.ts(11,27): er
|
||||
~~~~~~
|
||||
!!! error TS4105: Private or protected member 'a' cannot be accessed on a type parameter.
|
||||
type Z<T extends A & B> = T["a"];
|
||||
~~~~~~
|
||||
!!! error TS4105: Private or protected member 'a' cannot be accessed on a type parameter.
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
tests/cases/conformance/types/intersection/intersectionReduction.ts(38,4): error TS2339: Property 'kind' does not exist on type 'never'.
|
||||
The intersection 'A & B' was reduced to 'never' because property 'kind' has conflicting types in some constituents.
|
||||
tests/cases/conformance/types/intersection/intersectionReduction.ts(80,1): error TS2322: Type 'any' is not assignable to type 'never'.
|
||||
tests/cases/conformance/types/intersection/intersectionReduction.ts(81,1): error TS2322: Type 'any' is not assignable to type 'never'.
|
||||
|
||||
@ -44,6 +45,7 @@ tests/cases/conformance/types/intersection/intersectionReduction.ts(81,1): error
|
||||
ab.kind; // Error
|
||||
~~~~
|
||||
!!! error TS2339: Property 'kind' does not exist on type 'never'.
|
||||
!!! error TS2339: The intersection 'A & B' was reduced to 'never' because property 'kind' has conflicting types in some constituents.
|
||||
|
||||
declare let x: A | (B & C); // A
|
||||
let a: A = x;
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
tests/cases/conformance/types/intersection/intersectionReductionStrict.ts(38,4): error TS2339: Property 'kind' does not exist on type 'never'.
|
||||
The intersection 'A & B' was reduced to 'never' because property 'kind' has conflicting types in some constituents.
|
||||
tests/cases/conformance/types/intersection/intersectionReductionStrict.ts(69,1): error TS2322: Type 'any' is not assignable to type 'never'.
|
||||
tests/cases/conformance/types/intersection/intersectionReductionStrict.ts(70,1): error TS2322: Type 'any' is not assignable to type 'never'.
|
||||
|
||||
@ -44,6 +45,7 @@ tests/cases/conformance/types/intersection/intersectionReductionStrict.ts(70,1):
|
||||
ab.kind; // Error
|
||||
~~~~
|
||||
!!! error TS2339: Property 'kind' does not exist on type 'never'.
|
||||
!!! error TS2339: The intersection 'A & B' was reduced to 'never' because property 'kind' has conflicting types in some constituents.
|
||||
|
||||
declare let x: A | (B & C); // A
|
||||
let a: A = x;
|
||||
|
||||
@ -0,0 +1,70 @@
|
||||
tests/cases/compiler/intersectionWithConflictingPrivates.ts(5,4): error TS2339: Property 'y' does not exist on type 'never'.
|
||||
The intersection 'A & B' was reduced to 'never' because property 'x' exists in multiple constituents and is private in some.
|
||||
tests/cases/compiler/intersectionWithConflictingPrivates.ts(6,1): error TS2322: Type '{}' is not assignable to type 'never'.
|
||||
The intersection 'A & B' was reduced to 'never' because property 'x' exists in multiple constituents and is private in some.
|
||||
|
||||
|
||||
==== tests/cases/compiler/intersectionWithConflictingPrivates.ts (2 errors) ====
|
||||
class A { private x: unknown; y?: string; }
|
||||
class B { private x: unknown; y?: string; }
|
||||
|
||||
declare let ab: A & B;
|
||||
ab.y = 'hello';
|
||||
~
|
||||
!!! error TS2339: Property 'y' does not exist on type 'never'.
|
||||
!!! error TS2339: The intersection 'A & B' was reduced to 'never' because property 'x' exists in multiple constituents and is private in some.
|
||||
ab = {};
|
||||
~~
|
||||
!!! error TS2322: Type '{}' is not assignable to type 'never'.
|
||||
!!! error TS2322: The intersection 'A & B' was reduced to 'never' because property 'x' exists in multiple constituents and is private in some.
|
||||
|
||||
function f1(node: A | B) {
|
||||
if (node instanceof A || node instanceof A) {
|
||||
node; // A
|
||||
}
|
||||
else {
|
||||
node; // B
|
||||
}
|
||||
node; // A | B
|
||||
}
|
||||
|
||||
// Repro from #37659
|
||||
|
||||
abstract class ViewNode { }
|
||||
abstract class ViewRefNode extends ViewNode { }
|
||||
abstract class ViewRefFileNode extends ViewRefNode { }
|
||||
|
||||
class CommitFileNode extends ViewRefFileNode {
|
||||
private _id: any;
|
||||
}
|
||||
|
||||
class ResultsFileNode extends ViewRefFileNode {
|
||||
private _id: any;
|
||||
}
|
||||
|
||||
class StashFileNode extends CommitFileNode {
|
||||
private _id2: any;
|
||||
}
|
||||
|
||||
class StatusFileNode extends ViewNode {
|
||||
private _id: any;
|
||||
}
|
||||
|
||||
class Foo {
|
||||
private async foo(node: CommitFileNode | ResultsFileNode | StashFileNode) {
|
||||
if (
|
||||
!(node instanceof CommitFileNode) &&
|
||||
!(node instanceof StashFileNode) &&
|
||||
!(node instanceof ResultsFileNode)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
await this.bar(node);
|
||||
}
|
||||
|
||||
private async bar(node: CommitFileNode | ResultsFileNode | StashFileNode | StatusFileNode, options?: {}) {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
}
|
||||
|
||||
104
tests/baselines/reference/intersectionWithConflictingPrivates.js
Normal file
104
tests/baselines/reference/intersectionWithConflictingPrivates.js
Normal file
@ -0,0 +1,104 @@
|
||||
//// [intersectionWithConflictingPrivates.ts]
|
||||
class A { private x: unknown; y?: string; }
|
||||
class B { private x: unknown; y?: string; }
|
||||
|
||||
declare let ab: A & B;
|
||||
ab.y = 'hello';
|
||||
ab = {};
|
||||
|
||||
function f1(node: A | B) {
|
||||
if (node instanceof A || node instanceof A) {
|
||||
node; // A
|
||||
}
|
||||
else {
|
||||
node; // B
|
||||
}
|
||||
node; // A | B
|
||||
}
|
||||
|
||||
// Repro from #37659
|
||||
|
||||
abstract class ViewNode { }
|
||||
abstract class ViewRefNode extends ViewNode { }
|
||||
abstract class ViewRefFileNode extends ViewRefNode { }
|
||||
|
||||
class CommitFileNode extends ViewRefFileNode {
|
||||
private _id: any;
|
||||
}
|
||||
|
||||
class ResultsFileNode extends ViewRefFileNode {
|
||||
private _id: any;
|
||||
}
|
||||
|
||||
class StashFileNode extends CommitFileNode {
|
||||
private _id2: any;
|
||||
}
|
||||
|
||||
class StatusFileNode extends ViewNode {
|
||||
private _id: any;
|
||||
}
|
||||
|
||||
class Foo {
|
||||
private async foo(node: CommitFileNode | ResultsFileNode | StashFileNode) {
|
||||
if (
|
||||
!(node instanceof CommitFileNode) &&
|
||||
!(node instanceof StashFileNode) &&
|
||||
!(node instanceof ResultsFileNode)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
await this.bar(node);
|
||||
}
|
||||
|
||||
private async bar(node: CommitFileNode | ResultsFileNode | StashFileNode | StatusFileNode, options?: {}) {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [intersectionWithConflictingPrivates.js]
|
||||
"use strict";
|
||||
class A {
|
||||
}
|
||||
class B {
|
||||
}
|
||||
ab.y = 'hello';
|
||||
ab = {};
|
||||
function f1(node) {
|
||||
if (node instanceof A || node instanceof A) {
|
||||
node; // A
|
||||
}
|
||||
else {
|
||||
node; // B
|
||||
}
|
||||
node; // A | B
|
||||
}
|
||||
// Repro from #37659
|
||||
class ViewNode {
|
||||
}
|
||||
class ViewRefNode extends ViewNode {
|
||||
}
|
||||
class ViewRefFileNode extends ViewRefNode {
|
||||
}
|
||||
class CommitFileNode extends ViewRefFileNode {
|
||||
}
|
||||
class ResultsFileNode extends ViewRefFileNode {
|
||||
}
|
||||
class StashFileNode extends CommitFileNode {
|
||||
}
|
||||
class StatusFileNode extends ViewNode {
|
||||
}
|
||||
class Foo {
|
||||
async foo(node) {
|
||||
if (!(node instanceof CommitFileNode) &&
|
||||
!(node instanceof StashFileNode) &&
|
||||
!(node instanceof ResultsFileNode)) {
|
||||
return;
|
||||
}
|
||||
await this.bar(node);
|
||||
}
|
||||
async bar(node, options) {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,141 @@
|
||||
=== tests/cases/compiler/intersectionWithConflictingPrivates.ts ===
|
||||
class A { private x: unknown; y?: string; }
|
||||
>A : Symbol(A, Decl(intersectionWithConflictingPrivates.ts, 0, 0))
|
||||
>x : Symbol(A.x, Decl(intersectionWithConflictingPrivates.ts, 0, 9))
|
||||
>y : Symbol(A.y, Decl(intersectionWithConflictingPrivates.ts, 0, 29))
|
||||
|
||||
class B { private x: unknown; y?: string; }
|
||||
>B : Symbol(B, Decl(intersectionWithConflictingPrivates.ts, 0, 43))
|
||||
>x : Symbol(B.x, Decl(intersectionWithConflictingPrivates.ts, 1, 9))
|
||||
>y : Symbol(B.y, Decl(intersectionWithConflictingPrivates.ts, 1, 29))
|
||||
|
||||
declare let ab: A & B;
|
||||
>ab : Symbol(ab, Decl(intersectionWithConflictingPrivates.ts, 3, 11))
|
||||
>A : Symbol(A, Decl(intersectionWithConflictingPrivates.ts, 0, 0))
|
||||
>B : Symbol(B, Decl(intersectionWithConflictingPrivates.ts, 0, 43))
|
||||
|
||||
ab.y = 'hello';
|
||||
>ab : Symbol(ab, Decl(intersectionWithConflictingPrivates.ts, 3, 11))
|
||||
|
||||
ab = {};
|
||||
>ab : Symbol(ab, Decl(intersectionWithConflictingPrivates.ts, 3, 11))
|
||||
|
||||
function f1(node: A | B) {
|
||||
>f1 : Symbol(f1, Decl(intersectionWithConflictingPrivates.ts, 5, 8))
|
||||
>node : Symbol(node, Decl(intersectionWithConflictingPrivates.ts, 7, 12))
|
||||
>A : Symbol(A, Decl(intersectionWithConflictingPrivates.ts, 0, 0))
|
||||
>B : Symbol(B, Decl(intersectionWithConflictingPrivates.ts, 0, 43))
|
||||
|
||||
if (node instanceof A || node instanceof A) {
|
||||
>node : Symbol(node, Decl(intersectionWithConflictingPrivates.ts, 7, 12))
|
||||
>A : Symbol(A, Decl(intersectionWithConflictingPrivates.ts, 0, 0))
|
||||
>node : Symbol(node, Decl(intersectionWithConflictingPrivates.ts, 7, 12))
|
||||
>A : Symbol(A, Decl(intersectionWithConflictingPrivates.ts, 0, 0))
|
||||
|
||||
node; // A
|
||||
>node : Symbol(node, Decl(intersectionWithConflictingPrivates.ts, 7, 12))
|
||||
}
|
||||
else {
|
||||
node; // B
|
||||
>node : Symbol(node, Decl(intersectionWithConflictingPrivates.ts, 7, 12))
|
||||
}
|
||||
node; // A | B
|
||||
>node : Symbol(node, Decl(intersectionWithConflictingPrivates.ts, 7, 12))
|
||||
}
|
||||
|
||||
// Repro from #37659
|
||||
|
||||
abstract class ViewNode { }
|
||||
>ViewNode : Symbol(ViewNode, Decl(intersectionWithConflictingPrivates.ts, 15, 1))
|
||||
|
||||
abstract class ViewRefNode extends ViewNode { }
|
||||
>ViewRefNode : Symbol(ViewRefNode, Decl(intersectionWithConflictingPrivates.ts, 19, 27))
|
||||
>ViewNode : Symbol(ViewNode, Decl(intersectionWithConflictingPrivates.ts, 15, 1))
|
||||
|
||||
abstract class ViewRefFileNode extends ViewRefNode { }
|
||||
>ViewRefFileNode : Symbol(ViewRefFileNode, Decl(intersectionWithConflictingPrivates.ts, 20, 47))
|
||||
>ViewRefNode : Symbol(ViewRefNode, Decl(intersectionWithConflictingPrivates.ts, 19, 27))
|
||||
|
||||
class CommitFileNode extends ViewRefFileNode {
|
||||
>CommitFileNode : Symbol(CommitFileNode, Decl(intersectionWithConflictingPrivates.ts, 21, 54))
|
||||
>ViewRefFileNode : Symbol(ViewRefFileNode, Decl(intersectionWithConflictingPrivates.ts, 20, 47))
|
||||
|
||||
private _id: any;
|
||||
>_id : Symbol(CommitFileNode._id, Decl(intersectionWithConflictingPrivates.ts, 23, 46))
|
||||
}
|
||||
|
||||
class ResultsFileNode extends ViewRefFileNode {
|
||||
>ResultsFileNode : Symbol(ResultsFileNode, Decl(intersectionWithConflictingPrivates.ts, 25, 1))
|
||||
>ViewRefFileNode : Symbol(ViewRefFileNode, Decl(intersectionWithConflictingPrivates.ts, 20, 47))
|
||||
|
||||
private _id: any;
|
||||
>_id : Symbol(ResultsFileNode._id, Decl(intersectionWithConflictingPrivates.ts, 27, 47))
|
||||
}
|
||||
|
||||
class StashFileNode extends CommitFileNode {
|
||||
>StashFileNode : Symbol(StashFileNode, Decl(intersectionWithConflictingPrivates.ts, 29, 1))
|
||||
>CommitFileNode : Symbol(CommitFileNode, Decl(intersectionWithConflictingPrivates.ts, 21, 54))
|
||||
|
||||
private _id2: any;
|
||||
>_id2 : Symbol(StashFileNode._id2, Decl(intersectionWithConflictingPrivates.ts, 31, 44))
|
||||
}
|
||||
|
||||
class StatusFileNode extends ViewNode {
|
||||
>StatusFileNode : Symbol(StatusFileNode, Decl(intersectionWithConflictingPrivates.ts, 33, 1))
|
||||
>ViewNode : Symbol(ViewNode, Decl(intersectionWithConflictingPrivates.ts, 15, 1))
|
||||
|
||||
private _id: any;
|
||||
>_id : Symbol(StatusFileNode._id, Decl(intersectionWithConflictingPrivates.ts, 35, 39))
|
||||
}
|
||||
|
||||
class Foo {
|
||||
>Foo : Symbol(Foo, Decl(intersectionWithConflictingPrivates.ts, 37, 1))
|
||||
|
||||
private async foo(node: CommitFileNode | ResultsFileNode | StashFileNode) {
|
||||
>foo : Symbol(Foo.foo, Decl(intersectionWithConflictingPrivates.ts, 39, 11))
|
||||
>node : Symbol(node, Decl(intersectionWithConflictingPrivates.ts, 40, 20))
|
||||
>CommitFileNode : Symbol(CommitFileNode, Decl(intersectionWithConflictingPrivates.ts, 21, 54))
|
||||
>ResultsFileNode : Symbol(ResultsFileNode, Decl(intersectionWithConflictingPrivates.ts, 25, 1))
|
||||
>StashFileNode : Symbol(StashFileNode, Decl(intersectionWithConflictingPrivates.ts, 29, 1))
|
||||
|
||||
if (
|
||||
!(node instanceof CommitFileNode) &&
|
||||
>node : Symbol(node, Decl(intersectionWithConflictingPrivates.ts, 40, 20))
|
||||
>CommitFileNode : Symbol(CommitFileNode, Decl(intersectionWithConflictingPrivates.ts, 21, 54))
|
||||
|
||||
!(node instanceof StashFileNode) &&
|
||||
>node : Symbol(node, Decl(intersectionWithConflictingPrivates.ts, 40, 20))
|
||||
>StashFileNode : Symbol(StashFileNode, Decl(intersectionWithConflictingPrivates.ts, 29, 1))
|
||||
|
||||
!(node instanceof ResultsFileNode)
|
||||
>node : Symbol(node, Decl(intersectionWithConflictingPrivates.ts, 40, 20))
|
||||
>ResultsFileNode : Symbol(ResultsFileNode, Decl(intersectionWithConflictingPrivates.ts, 25, 1))
|
||||
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
await this.bar(node);
|
||||
>this.bar : Symbol(Foo.bar, Decl(intersectionWithConflictingPrivates.ts, 50, 2))
|
||||
>this : Symbol(Foo, Decl(intersectionWithConflictingPrivates.ts, 37, 1))
|
||||
>bar : Symbol(Foo.bar, Decl(intersectionWithConflictingPrivates.ts, 50, 2))
|
||||
>node : Symbol(node, Decl(intersectionWithConflictingPrivates.ts, 40, 20))
|
||||
}
|
||||
|
||||
private async bar(node: CommitFileNode | ResultsFileNode | StashFileNode | StatusFileNode, options?: {}) {
|
||||
>bar : Symbol(Foo.bar, Decl(intersectionWithConflictingPrivates.ts, 50, 2))
|
||||
>node : Symbol(node, Decl(intersectionWithConflictingPrivates.ts, 52, 20))
|
||||
>CommitFileNode : Symbol(CommitFileNode, Decl(intersectionWithConflictingPrivates.ts, 21, 54))
|
||||
>ResultsFileNode : Symbol(ResultsFileNode, Decl(intersectionWithConflictingPrivates.ts, 25, 1))
|
||||
>StashFileNode : Symbol(StashFileNode, Decl(intersectionWithConflictingPrivates.ts, 29, 1))
|
||||
>StatusFileNode : Symbol(StatusFileNode, Decl(intersectionWithConflictingPrivates.ts, 33, 1))
|
||||
>options : Symbol(options, Decl(intersectionWithConflictingPrivates.ts, 52, 92))
|
||||
|
||||
return Promise.resolve(undefined);
|
||||
>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))
|
||||
>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --))
|
||||
>undefined : Symbol(undefined)
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,153 @@
|
||||
=== tests/cases/compiler/intersectionWithConflictingPrivates.ts ===
|
||||
class A { private x: unknown; y?: string; }
|
||||
>A : A
|
||||
>x : unknown
|
||||
>y : string | undefined
|
||||
|
||||
class B { private x: unknown; y?: string; }
|
||||
>B : B
|
||||
>x : unknown
|
||||
>y : string | undefined
|
||||
|
||||
declare let ab: A & B;
|
||||
>ab : never
|
||||
|
||||
ab.y = 'hello';
|
||||
>ab.y = 'hello' : "hello"
|
||||
>ab.y : any
|
||||
>ab : never
|
||||
>y : any
|
||||
>'hello' : "hello"
|
||||
|
||||
ab = {};
|
||||
>ab = {} : {}
|
||||
>ab : never
|
||||
>{} : {}
|
||||
|
||||
function f1(node: A | B) {
|
||||
>f1 : (node: A | B) => void
|
||||
>node : A | B
|
||||
|
||||
if (node instanceof A || node instanceof A) {
|
||||
>node instanceof A || node instanceof A : boolean
|
||||
>node instanceof A : boolean
|
||||
>node : A | B
|
||||
>A : typeof A
|
||||
>node instanceof A : boolean
|
||||
>node : B
|
||||
>A : typeof A
|
||||
|
||||
node; // A
|
||||
>node : A
|
||||
}
|
||||
else {
|
||||
node; // B
|
||||
>node : B
|
||||
}
|
||||
node; // A | B
|
||||
>node : A | B
|
||||
}
|
||||
|
||||
// Repro from #37659
|
||||
|
||||
abstract class ViewNode { }
|
||||
>ViewNode : ViewNode
|
||||
|
||||
abstract class ViewRefNode extends ViewNode { }
|
||||
>ViewRefNode : ViewRefNode
|
||||
>ViewNode : ViewNode
|
||||
|
||||
abstract class ViewRefFileNode extends ViewRefNode { }
|
||||
>ViewRefFileNode : ViewRefFileNode
|
||||
>ViewRefNode : ViewRefNode
|
||||
|
||||
class CommitFileNode extends ViewRefFileNode {
|
||||
>CommitFileNode : CommitFileNode
|
||||
>ViewRefFileNode : ViewRefFileNode
|
||||
|
||||
private _id: any;
|
||||
>_id : any
|
||||
}
|
||||
|
||||
class ResultsFileNode extends ViewRefFileNode {
|
||||
>ResultsFileNode : ResultsFileNode
|
||||
>ViewRefFileNode : ViewRefFileNode
|
||||
|
||||
private _id: any;
|
||||
>_id : any
|
||||
}
|
||||
|
||||
class StashFileNode extends CommitFileNode {
|
||||
>StashFileNode : StashFileNode
|
||||
>CommitFileNode : CommitFileNode
|
||||
|
||||
private _id2: any;
|
||||
>_id2 : any
|
||||
}
|
||||
|
||||
class StatusFileNode extends ViewNode {
|
||||
>StatusFileNode : StatusFileNode
|
||||
>ViewNode : ViewNode
|
||||
|
||||
private _id: any;
|
||||
>_id : any
|
||||
}
|
||||
|
||||
class Foo {
|
||||
>Foo : Foo
|
||||
|
||||
private async foo(node: CommitFileNode | ResultsFileNode | StashFileNode) {
|
||||
>foo : (node: CommitFileNode | ResultsFileNode | StashFileNode) => Promise<void>
|
||||
>node : CommitFileNode | ResultsFileNode | StashFileNode
|
||||
|
||||
if (
|
||||
!(node instanceof CommitFileNode) &&
|
||||
>!(node instanceof CommitFileNode) && !(node instanceof StashFileNode) && !(node instanceof ResultsFileNode) : boolean
|
||||
>!(node instanceof CommitFileNode) && !(node instanceof StashFileNode) : boolean
|
||||
>!(node instanceof CommitFileNode) : boolean
|
||||
>(node instanceof CommitFileNode) : boolean
|
||||
>node instanceof CommitFileNode : boolean
|
||||
>node : CommitFileNode | ResultsFileNode | StashFileNode
|
||||
>CommitFileNode : typeof CommitFileNode
|
||||
|
||||
!(node instanceof StashFileNode) &&
|
||||
>!(node instanceof StashFileNode) : boolean
|
||||
>(node instanceof StashFileNode) : boolean
|
||||
>node instanceof StashFileNode : boolean
|
||||
>node : ResultsFileNode
|
||||
>StashFileNode : typeof StashFileNode
|
||||
|
||||
!(node instanceof ResultsFileNode)
|
||||
>!(node instanceof ResultsFileNode) : boolean
|
||||
>(node instanceof ResultsFileNode) : boolean
|
||||
>node instanceof ResultsFileNode : boolean
|
||||
>node : ResultsFileNode
|
||||
>ResultsFileNode : typeof ResultsFileNode
|
||||
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
await this.bar(node);
|
||||
>await this.bar(node) : undefined
|
||||
>this.bar(node) : Promise<undefined>
|
||||
>this.bar : (node: CommitFileNode | ResultsFileNode | StashFileNode | StatusFileNode, options?: {} | undefined) => Promise<undefined>
|
||||
>this : this
|
||||
>bar : (node: CommitFileNode | ResultsFileNode | StashFileNode | StatusFileNode, options?: {} | undefined) => Promise<undefined>
|
||||
>node : CommitFileNode | ResultsFileNode
|
||||
}
|
||||
|
||||
private async bar(node: CommitFileNode | ResultsFileNode | StashFileNode | StatusFileNode, options?: {}) {
|
||||
>bar : (node: CommitFileNode | ResultsFileNode | StashFileNode | StatusFileNode, options?: {} | undefined) => Promise<undefined>
|
||||
>node : CommitFileNode | ResultsFileNode | StashFileNode | StatusFileNode
|
||||
>options : {} | undefined
|
||||
|
||||
return Promise.resolve(undefined);
|
||||
>Promise.resolve(undefined) : Promise<undefined>
|
||||
>Promise.resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
|
||||
>Promise : PromiseConstructor
|
||||
>resolve : { <T>(value: T | PromiseLike<T>): Promise<T>; (): Promise<void>; }
|
||||
>undefined : undefined
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,25 +1,27 @@
|
||||
tests/cases/conformance/classes/mixinAccessModifiers.ts(38,4): error TS2546: Property 'p' has conflicting declarations and is inaccessible in type 'Private & Private2'.
|
||||
tests/cases/conformance/classes/mixinAccessModifiers.ts(42,4): error TS2546: Property 'p' has conflicting declarations and is inaccessible in type 'Private & Protected'.
|
||||
tests/cases/conformance/classes/mixinAccessModifiers.ts(46,4): error TS2546: Property 'p' has conflicting declarations and is inaccessible in type 'Private & Public'.
|
||||
tests/cases/conformance/classes/mixinAccessModifiers.ts(38,4): error TS2339: Property 'p' does not exist on type 'never'.
|
||||
The intersection 'Private & Private2' was reduced to 'never' because property 'p' exists in multiple constituents and is private in some.
|
||||
tests/cases/conformance/classes/mixinAccessModifiers.ts(42,4): error TS2339: Property 'p' does not exist on type 'never'.
|
||||
The intersection 'Private & Protected' was reduced to 'never' because property 'p' exists in multiple constituents and is private in some.
|
||||
tests/cases/conformance/classes/mixinAccessModifiers.ts(46,4): error TS2339: Property 'p' does not exist on type 'never'.
|
||||
The intersection 'Private & Public' was reduced to 'never' because property 'p' exists in multiple constituents and is private in some.
|
||||
tests/cases/conformance/classes/mixinAccessModifiers.ts(50,4): error TS2445: Property 'p' is protected and only accessible within class 'Protected & Protected2' and its subclasses.
|
||||
tests/cases/conformance/classes/mixinAccessModifiers.ts(65,7): error TS2415: Class 'C1' incorrectly extends base class 'Private & Private2'.
|
||||
Type 'C1' is not assignable to type 'Private'.
|
||||
Property 'p' has conflicting declarations and is inaccessible in type 'C1'.
|
||||
tests/cases/conformance/classes/mixinAccessModifiers.ts(66,7): error TS2415: Class 'C2' incorrectly extends base class 'Private & Protected'.
|
||||
Type 'C2' is not assignable to type 'Private'.
|
||||
Property 'p' has conflicting declarations and is inaccessible in type 'C2'.
|
||||
tests/cases/conformance/classes/mixinAccessModifiers.ts(67,7): error TS2415: Class 'C3' incorrectly extends base class 'Private & Public'.
|
||||
Type 'C3' is not assignable to type 'Private'.
|
||||
Property 'p' has conflicting declarations and is inaccessible in type 'C3'.
|
||||
tests/cases/conformance/classes/mixinAccessModifiers.ts(65,18): error TS2509: Base constructor return type 'never' is not an object type or intersection of object types with statically known members.
|
||||
The intersection 'Private & Private2' was reduced to 'never' because property 'p' exists in multiple constituents and is private in some.
|
||||
tests/cases/conformance/classes/mixinAccessModifiers.ts(66,18): error TS2509: Base constructor return type 'never' is not an object type or intersection of object types with statically known members.
|
||||
The intersection 'Private & Protected' was reduced to 'never' because property 'p' exists in multiple constituents and is private in some.
|
||||
tests/cases/conformance/classes/mixinAccessModifiers.ts(67,18): error TS2509: Base constructor return type 'never' is not an object type or intersection of object types with statically known members.
|
||||
The intersection 'Private & Public' was reduced to 'never' because property 'p' exists in multiple constituents and is private in some.
|
||||
tests/cases/conformance/classes/mixinAccessModifiers.ts(84,6): error TS2445: Property 'p' is protected and only accessible within class 'C4' and its subclasses.
|
||||
tests/cases/conformance/classes/mixinAccessModifiers.ts(89,6): error TS2445: Property 's' is protected and only accessible within class 'typeof C4' and its subclasses.
|
||||
tests/cases/conformance/classes/mixinAccessModifiers.ts(97,6): error TS2445: Property 'p' is protected and only accessible within class 'C4' and its subclasses.
|
||||
tests/cases/conformance/classes/mixinAccessModifiers.ts(102,6): error TS2445: Property 's' is protected and only accessible within class 'typeof C4' and its subclasses.
|
||||
tests/cases/conformance/classes/mixinAccessModifiers.ts(119,4): error TS2341: Property 'privateMethod' is private and only accessible within class 'ProtectedGeneric<T>'.
|
||||
tests/cases/conformance/classes/mixinAccessModifiers.ts(120,4): error TS2445: Property 'protectedMethod' is protected and only accessible within class 'ProtectedGeneric<T>' and its subclasses.
|
||||
tests/cases/conformance/classes/mixinAccessModifiers.ts(124,4): error TS2546: Property 'privateMethod' has conflicting declarations and is inaccessible in type 'ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }>'.
|
||||
tests/cases/conformance/classes/mixinAccessModifiers.ts(125,4): error TS2445: Property 'protectedMethod' is protected and only accessible within class 'ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }>' and its subclasses.
|
||||
tests/cases/conformance/classes/mixinAccessModifiers.ts(129,4): error TS2546: Property 'privateMethod' has conflicting declarations and is inaccessible in type 'ProtectedGeneric<{ a: void; }> & ProtectedGeneric<{ a: void; b: void; }>'.
|
||||
tests/cases/conformance/classes/mixinAccessModifiers.ts(124,4): error TS2339: Property 'privateMethod' does not exist on type 'never'.
|
||||
The intersection 'ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }>' was reduced to 'never' because property 'privateMethod' exists in multiple constituents and is private in some.
|
||||
tests/cases/conformance/classes/mixinAccessModifiers.ts(125,4): error TS2339: Property 'protectedMethod' does not exist on type 'never'.
|
||||
The intersection 'ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }>' was reduced to 'never' because property 'privateMethod' exists in multiple constituents and is private in some.
|
||||
tests/cases/conformance/classes/mixinAccessModifiers.ts(129,4): error TS2341: Property 'privateMethod' is private and only accessible within class 'ProtectedGeneric<T>'.
|
||||
tests/cases/conformance/classes/mixinAccessModifiers.ts(130,4): error TS2445: Property 'protectedMethod' is protected and only accessible within class 'ProtectedGeneric<T>' and its subclasses.
|
||||
|
||||
|
||||
@ -63,19 +65,22 @@ tests/cases/conformance/classes/mixinAccessModifiers.ts(130,4): error TS2445: Pr
|
||||
function f1(x: Private & Private2) {
|
||||
x.p; // Error, private constituent makes property inaccessible
|
||||
~
|
||||
!!! error TS2546: Property 'p' has conflicting declarations and is inaccessible in type 'Private & Private2'.
|
||||
!!! error TS2339: Property 'p' does not exist on type 'never'.
|
||||
!!! error TS2339: The intersection 'Private & Private2' was reduced to 'never' because property 'p' exists in multiple constituents and is private in some.
|
||||
}
|
||||
|
||||
function f2(x: Private & Protected) {
|
||||
x.p; // Error, private constituent makes property inaccessible
|
||||
~
|
||||
!!! error TS2546: Property 'p' has conflicting declarations and is inaccessible in type 'Private & Protected'.
|
||||
!!! error TS2339: Property 'p' does not exist on type 'never'.
|
||||
!!! error TS2339: The intersection 'Private & Protected' was reduced to 'never' because property 'p' exists in multiple constituents and is private in some.
|
||||
}
|
||||
|
||||
function f3(x: Private & Public) {
|
||||
x.p; // Error, private constituent makes property inaccessible
|
||||
~
|
||||
!!! error TS2546: Property 'p' has conflicting declarations and is inaccessible in type 'Private & Public'.
|
||||
!!! error TS2339: Property 'p' does not exist on type 'never'.
|
||||
!!! error TS2339: The intersection 'Private & Public' was reduced to 'never' because property 'p' exists in multiple constituents and is private in some.
|
||||
}
|
||||
|
||||
function f4(x: Protected & Protected2) {
|
||||
@ -97,20 +102,17 @@ tests/cases/conformance/classes/mixinAccessModifiers.ts(130,4): error TS2445: Pr
|
||||
// Can't derive from type with inaccessible properties
|
||||
|
||||
class C1 extends Mix(Private, Private2) {}
|
||||
~~
|
||||
!!! error TS2415: Class 'C1' incorrectly extends base class 'Private & Private2'.
|
||||
!!! error TS2415: Type 'C1' is not assignable to type 'Private'.
|
||||
!!! error TS2415: Property 'p' has conflicting declarations and is inaccessible in type 'C1'.
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2509: Base constructor return type 'never' is not an object type or intersection of object types with statically known members.
|
||||
!!! error TS2509: The intersection 'Private & Private2' was reduced to 'never' because property 'p' exists in multiple constituents and is private in some.
|
||||
class C2 extends Mix(Private, Protected) {}
|
||||
~~
|
||||
!!! error TS2415: Class 'C2' incorrectly extends base class 'Private & Protected'.
|
||||
!!! error TS2415: Type 'C2' is not assignable to type 'Private'.
|
||||
!!! error TS2415: Property 'p' has conflicting declarations and is inaccessible in type 'C2'.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2509: Base constructor return type 'never' is not an object type or intersection of object types with statically known members.
|
||||
!!! error TS2509: The intersection 'Private & Protected' was reduced to 'never' because property 'p' exists in multiple constituents and is private in some.
|
||||
class C3 extends Mix(Private, Public) {}
|
||||
~~
|
||||
!!! error TS2415: Class 'C3' incorrectly extends base class 'Private & Public'.
|
||||
!!! error TS2415: Type 'C3' is not assignable to type 'Private'.
|
||||
!!! error TS2415: Property 'p' has conflicting declarations and is inaccessible in type 'C3'.
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2509: Base constructor return type 'never' is not an object type or intersection of object types with statically known members.
|
||||
!!! error TS2509: The intersection 'Private & Public' was reduced to 'never' because property 'p' exists in multiple constituents and is private in some.
|
||||
|
||||
class C4 extends Mix(Protected, Protected2) {
|
||||
f(c4: C4, c5: C5, c6: C6) {
|
||||
@ -181,16 +183,18 @@ tests/cases/conformance/classes/mixinAccessModifiers.ts(130,4): error TS2445: Pr
|
||||
function f8(x: ProtectedGeneric<{a: void;}> & ProtectedGeneric2<{a:void;b:void;}>) {
|
||||
x.privateMethod(); // Error, private constituent makes method inaccessible
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2546: Property 'privateMethod' has conflicting declarations and is inaccessible in type 'ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }>'.
|
||||
!!! error TS2339: Property 'privateMethod' does not exist on type 'never'.
|
||||
!!! error TS2339: The intersection 'ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }>' was reduced to 'never' because property 'privateMethod' exists in multiple constituents and is private in some.
|
||||
x.protectedMethod(); // Error, protected when all constituents are protected
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2445: Property 'protectedMethod' is protected and only accessible within class 'ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }>' and its subclasses.
|
||||
!!! error TS2339: Property 'protectedMethod' does not exist on type 'never'.
|
||||
!!! error TS2339: The intersection 'ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }>' was reduced to 'never' because property 'privateMethod' exists in multiple constituents and is private in some.
|
||||
}
|
||||
|
||||
function f9(x: ProtectedGeneric<{a: void;}> & ProtectedGeneric<{a:void;b:void;}>) {
|
||||
x.privateMethod(); // Error, private constituent makes method inaccessible
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2546: Property 'privateMethod' has conflicting declarations and is inaccessible in type 'ProtectedGeneric<{ a: void; }> & ProtectedGeneric<{ a: void; b: void; }>'.
|
||||
!!! error TS2341: Property 'privateMethod' is private and only accessible within class 'ProtectedGeneric<T>'.
|
||||
x.protectedMethod(); // Error, protected when all constituents are protected
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2445: Property 'protectedMethod' is protected and only accessible within class 'ProtectedGeneric<T>' and its subclasses.
|
||||
|
||||
@ -82,9 +82,7 @@ function f1(x: Private & Private2) {
|
||||
>Private2 : Symbol(Private2, Decl(mixinAccessModifiers.ts, 5, 1))
|
||||
|
||||
x.p; // Error, private constituent makes property inaccessible
|
||||
>x.p : Symbol(p, Decl(mixinAccessModifiers.ts, 3, 32), Decl(mixinAccessModifiers.ts, 8, 32))
|
||||
>x : Symbol(x, Decl(mixinAccessModifiers.ts, 36, 12))
|
||||
>p : Symbol(p, Decl(mixinAccessModifiers.ts, 3, 32), Decl(mixinAccessModifiers.ts, 8, 32))
|
||||
}
|
||||
|
||||
function f2(x: Private & Protected) {
|
||||
@ -94,9 +92,7 @@ function f2(x: Private & Protected) {
|
||||
>Protected : Symbol(Protected, Decl(mixinAccessModifiers.ts, 10, 1))
|
||||
|
||||
x.p; // Error, private constituent makes property inaccessible
|
||||
>x.p : Symbol(p, Decl(mixinAccessModifiers.ts, 3, 32), Decl(mixinAccessModifiers.ts, 13, 32))
|
||||
>x : Symbol(x, Decl(mixinAccessModifiers.ts, 40, 12))
|
||||
>p : Symbol(p, Decl(mixinAccessModifiers.ts, 3, 32), Decl(mixinAccessModifiers.ts, 13, 32))
|
||||
}
|
||||
|
||||
function f3(x: Private & Public) {
|
||||
@ -106,9 +102,7 @@ function f3(x: Private & Public) {
|
||||
>Public : Symbol(Public, Decl(mixinAccessModifiers.ts, 22, 1))
|
||||
|
||||
x.p; // Error, private constituent makes property inaccessible
|
||||
>x.p : Symbol(p, Decl(mixinAccessModifiers.ts, 3, 32), Decl(mixinAccessModifiers.ts, 25, 32))
|
||||
>x : Symbol(x, Decl(mixinAccessModifiers.ts, 44, 12))
|
||||
>p : Symbol(p, Decl(mixinAccessModifiers.ts, 3, 32), Decl(mixinAccessModifiers.ts, 25, 32))
|
||||
}
|
||||
|
||||
function f4(x: Protected & Protected2) {
|
||||
@ -377,14 +371,10 @@ function f8(x: ProtectedGeneric<{a: void;}> & ProtectedGeneric2<{a:void;b:void;}
|
||||
>b : Symbol(b, Decl(mixinAccessModifiers.ts, 122, 72))
|
||||
|
||||
x.privateMethod(); // Error, private constituent makes method inaccessible
|
||||
>x.privateMethod : Symbol(privateMethod, Decl(mixinAccessModifiers.ts, 107, 27), Decl(mixinAccessModifiers.ts, 112, 28))
|
||||
>x : Symbol(x, Decl(mixinAccessModifiers.ts, 122, 12))
|
||||
>privateMethod : Symbol(privateMethod, Decl(mixinAccessModifiers.ts, 107, 27), Decl(mixinAccessModifiers.ts, 112, 28))
|
||||
|
||||
x.protectedMethod(); // Error, protected when all constituents are protected
|
||||
>x.protectedMethod : Symbol(protectedMethod, Decl(mixinAccessModifiers.ts, 108, 27), Decl(mixinAccessModifiers.ts, 113, 27))
|
||||
>x : Symbol(x, Decl(mixinAccessModifiers.ts, 122, 12))
|
||||
>protectedMethod : Symbol(protectedMethod, Decl(mixinAccessModifiers.ts, 108, 27), Decl(mixinAccessModifiers.ts, 113, 27))
|
||||
}
|
||||
|
||||
function f9(x: ProtectedGeneric<{a: void;}> & ProtectedGeneric<{a:void;b:void;}>) {
|
||||
|
||||
@ -77,32 +77,32 @@ class Public2 {
|
||||
|
||||
function f1(x: Private & Private2) {
|
||||
>f1 : (x: Private & Private2) => void
|
||||
>x : Private & Private2
|
||||
>x : never
|
||||
|
||||
x.p; // Error, private constituent makes property inaccessible
|
||||
>x.p : string
|
||||
>x : Private & Private2
|
||||
>p : string
|
||||
>x.p : any
|
||||
>x : never
|
||||
>p : any
|
||||
}
|
||||
|
||||
function f2(x: Private & Protected) {
|
||||
>f2 : (x: Private & Protected) => void
|
||||
>x : Private & Protected
|
||||
>x : never
|
||||
|
||||
x.p; // Error, private constituent makes property inaccessible
|
||||
>x.p : string
|
||||
>x : Private & Protected
|
||||
>p : string
|
||||
>x.p : any
|
||||
>x : never
|
||||
>p : any
|
||||
}
|
||||
|
||||
function f3(x: Private & Public) {
|
||||
>f3 : (x: Private & Public) => void
|
||||
>x : Private & Public
|
||||
>x : never
|
||||
|
||||
x.p; // Error, private constituent makes property inaccessible
|
||||
>x.p : string
|
||||
>x : Private & Public
|
||||
>p : string
|
||||
>x.p : any
|
||||
>x : never
|
||||
>p : any
|
||||
}
|
||||
|
||||
function f4(x: Protected & Protected2) {
|
||||
@ -144,21 +144,21 @@ declare function Mix<T, U>(c1: T, c2: U): T & U;
|
||||
|
||||
class C1 extends Mix(Private, Private2) {}
|
||||
>C1 : C1
|
||||
>Mix(Private, Private2) : Private & Private2
|
||||
>Mix(Private, Private2) : typeof Private & typeof Private2
|
||||
>Mix : <T, U>(c1: T, c2: U) => T & U
|
||||
>Private : typeof Private
|
||||
>Private2 : typeof Private2
|
||||
|
||||
class C2 extends Mix(Private, Protected) {}
|
||||
>C2 : C2
|
||||
>Mix(Private, Protected) : Private & Protected
|
||||
>Mix(Private, Protected) : typeof Private & typeof Protected
|
||||
>Mix : <T, U>(c1: T, c2: U) => T & U
|
||||
>Private : typeof Private
|
||||
>Protected : typeof Protected
|
||||
|
||||
class C3 extends Mix(Private, Public) {}
|
||||
>C3 : C3
|
||||
>Mix(Private, Public) : Private & Public
|
||||
>Mix(Private, Public) : typeof Private & typeof Public
|
||||
>Mix : <T, U>(c1: T, c2: U) => T & U
|
||||
>Private : typeof Private
|
||||
>Public : typeof Public
|
||||
@ -346,22 +346,22 @@ function f7(x: ProtectedGeneric<{}> & ProtectedGeneric<{}>) {
|
||||
|
||||
function f8(x: ProtectedGeneric<{a: void;}> & ProtectedGeneric2<{a:void;b:void;}>) {
|
||||
>f8 : (x: ProtectedGeneric<{ a: void;}> & ProtectedGeneric2<{ a: void; b: void;}>) => void
|
||||
>x : ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }>
|
||||
>x : never
|
||||
>a : void
|
||||
>a : void
|
||||
>b : void
|
||||
|
||||
x.privateMethod(); // Error, private constituent makes method inaccessible
|
||||
>x.privateMethod() : void
|
||||
>x.privateMethod : (() => void) & (() => void)
|
||||
>x : ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }>
|
||||
>privateMethod : (() => void) & (() => void)
|
||||
>x.privateMethod() : any
|
||||
>x.privateMethod : any
|
||||
>x : never
|
||||
>privateMethod : any
|
||||
|
||||
x.protectedMethod(); // Error, protected when all constituents are protected
|
||||
>x.protectedMethod() : void
|
||||
>x.protectedMethod : (() => void) & (() => void)
|
||||
>x : ProtectedGeneric<{ a: void; }> & ProtectedGeneric2<{ a: void; b: void; }>
|
||||
>protectedMethod : (() => void) & (() => void)
|
||||
>x.protectedMethod() : any
|
||||
>x.protectedMethod : any
|
||||
>x : never
|
||||
>protectedMethod : any
|
||||
}
|
||||
|
||||
function f9(x: ProtectedGeneric<{a: void;}> & ProtectedGeneric<{a:void;b:void;}>) {
|
||||
|
||||
@ -1,14 +1,26 @@
|
||||
tests/cases/compiler/mixinPrivateAndProtected.ts(46,3): error TS2445: Property 'ptd' is protected and only accessible within class 'A' and its subclasses.
|
||||
tests/cases/compiler/mixinPrivateAndProtected.ts(47,3): error TS2341: Property 'pvt' is private and only accessible within class 'A'.
|
||||
tests/cases/compiler/mixinPrivateAndProtected.ts(50,4): error TS2445: Property 'ptd' is protected and only accessible within class 'mixB<typeof A>.(Anonymous class) & A' and its subclasses.
|
||||
tests/cases/compiler/mixinPrivateAndProtected.ts(51,4): error TS2546: Property 'pvt' has conflicting declarations and is inaccessible in type 'mixB<typeof A>.(Anonymous class) & A'.
|
||||
tests/cases/compiler/mixinPrivateAndProtected.ts(54,5): error TS2445: Property 'ptd' is protected and only accessible within class 'mixC<{ new (...args: any[]): mixB<typeof A>.(Anonymous class); prototype: mixB<any>.(Anonymous class); } & typeof A>.(Anonymous class) & mixB<typeof A>.(Anonymous class) & A' and its subclasses.
|
||||
tests/cases/compiler/mixinPrivateAndProtected.ts(55,5): error TS2546: Property 'pvt' has conflicting declarations and is inaccessible in type 'mixC<{ new (...args: any[]): mixB<typeof A>.(Anonymous class); prototype: mixB<any>.(Anonymous class); } & typeof A>.(Anonymous class) & mixB<typeof A>.(Anonymous class) & A'.
|
||||
tests/cases/compiler/mixinPrivateAndProtected.ts(58,6): error TS2445: Property 'ptd' is protected and only accessible within class 'mixC<{ new (...args: any[]): mixB2<typeof A>.(Anonymous class); prototype: mixB2<any>.(Anonymous class); } & typeof A>.(Anonymous class) & mixB2<typeof A>.(Anonymous class) & A' and its subclasses.
|
||||
tests/cases/compiler/mixinPrivateAndProtected.ts(59,6): error TS2546: Property 'pvt' has conflicting declarations and is inaccessible in type 'mixC<{ new (...args: any[]): mixB2<typeof A>.(Anonymous class); prototype: mixB2<any>.(Anonymous class); } & typeof A>.(Anonymous class) & mixB2<typeof A>.(Anonymous class) & A'.
|
||||
tests/cases/compiler/mixinPrivateAndProtected.ts(49,4): error TS2339: Property 'pb' does not exist on type 'never'.
|
||||
The intersection 'mixB<typeof A>.(Anonymous class) & A' was reduced to 'never' because property 'pvt' exists in multiple constituents and is private in some.
|
||||
tests/cases/compiler/mixinPrivateAndProtected.ts(50,4): error TS2339: Property 'ptd' does not exist on type 'never'.
|
||||
The intersection 'mixB<typeof A>.(Anonymous class) & A' was reduced to 'never' because property 'pvt' exists in multiple constituents and is private in some.
|
||||
tests/cases/compiler/mixinPrivateAndProtected.ts(51,4): error TS2339: Property 'pvt' does not exist on type 'never'.
|
||||
The intersection 'mixB<typeof A>.(Anonymous class) & A' was reduced to 'never' because property 'pvt' exists in multiple constituents and is private in some.
|
||||
tests/cases/compiler/mixinPrivateAndProtected.ts(53,5): error TS2339: Property 'pb' does not exist on type 'never'.
|
||||
The intersection 'mixC<{ new (...args: any[]): mixB<typeof A>.(Anonymous class); prototype: mixB<any>.(Anonymous class); } & typeof A>.(Anonymous class) & mixB<typeof A>.(Anonymous class) & A' was reduced to 'never' because property 'pvt' exists in multiple constituents and is private in some.
|
||||
tests/cases/compiler/mixinPrivateAndProtected.ts(54,5): error TS2339: Property 'ptd' does not exist on type 'never'.
|
||||
The intersection 'mixC<{ new (...args: any[]): mixB<typeof A>.(Anonymous class); prototype: mixB<any>.(Anonymous class); } & typeof A>.(Anonymous class) & mixB<typeof A>.(Anonymous class) & A' was reduced to 'never' because property 'pvt' exists in multiple constituents and is private in some.
|
||||
tests/cases/compiler/mixinPrivateAndProtected.ts(55,5): error TS2339: Property 'pvt' does not exist on type 'never'.
|
||||
The intersection 'mixC<{ new (...args: any[]): mixB<typeof A>.(Anonymous class); prototype: mixB<any>.(Anonymous class); } & typeof A>.(Anonymous class) & mixB<typeof A>.(Anonymous class) & A' was reduced to 'never' because property 'pvt' exists in multiple constituents and is private in some.
|
||||
tests/cases/compiler/mixinPrivateAndProtected.ts(57,6): error TS2339: Property 'pb' does not exist on type 'never'.
|
||||
The intersection 'mixC<{ new (...args: any[]): mixB2<typeof A>.(Anonymous class); prototype: mixB2<any>.(Anonymous class); } & typeof A>.(Anonymous class) & mixB2<typeof A>.(Anonymous class) & A' was reduced to 'never' because property 'pvt' exists in multiple constituents and is private in some.
|
||||
tests/cases/compiler/mixinPrivateAndProtected.ts(58,6): error TS2339: Property 'ptd' does not exist on type 'never'.
|
||||
The intersection 'mixC<{ new (...args: any[]): mixB2<typeof A>.(Anonymous class); prototype: mixB2<any>.(Anonymous class); } & typeof A>.(Anonymous class) & mixB2<typeof A>.(Anonymous class) & A' was reduced to 'never' because property 'pvt' exists in multiple constituents and is private in some.
|
||||
tests/cases/compiler/mixinPrivateAndProtected.ts(59,6): error TS2339: Property 'pvt' does not exist on type 'never'.
|
||||
The intersection 'mixC<{ new (...args: any[]): mixB2<typeof A>.(Anonymous class); prototype: mixB2<any>.(Anonymous class); } & typeof A>.(Anonymous class) & mixB2<typeof A>.(Anonymous class) & A' was reduced to 'never' because property 'pvt' exists in multiple constituents and is private in some.
|
||||
|
||||
|
||||
==== tests/cases/compiler/mixinPrivateAndProtected.ts (8 errors) ====
|
||||
==== tests/cases/compiler/mixinPrivateAndProtected.ts (11 errors) ====
|
||||
// Repro from #13830
|
||||
|
||||
type Constructor<T> = new(...args: any[]) => T;
|
||||
@ -62,28 +74,43 @@ tests/cases/compiler/mixinPrivateAndProtected.ts(59,6): error TS2546: Property '
|
||||
!!! error TS2341: Property 'pvt' is private and only accessible within class 'A'.
|
||||
|
||||
ab.pb.toFixed();
|
||||
~~
|
||||
!!! error TS2339: Property 'pb' does not exist on type 'never'.
|
||||
!!! error TS2339: The intersection 'mixB<typeof A>.(Anonymous class) & A' was reduced to 'never' because property 'pvt' exists in multiple constituents and is private in some.
|
||||
ab.ptd.toFixed(); // Error
|
||||
~~~
|
||||
!!! error TS2445: Property 'ptd' is protected and only accessible within class 'mixB<typeof A>.(Anonymous class) & A' and its subclasses.
|
||||
!!! error TS2339: Property 'ptd' does not exist on type 'never'.
|
||||
!!! error TS2339: The intersection 'mixB<typeof A>.(Anonymous class) & A' was reduced to 'never' because property 'pvt' exists in multiple constituents and is private in some.
|
||||
ab.pvt.toFixed(); // Error
|
||||
~~~
|
||||
!!! error TS2546: Property 'pvt' has conflicting declarations and is inaccessible in type 'mixB<typeof A>.(Anonymous class) & A'.
|
||||
!!! error TS2339: Property 'pvt' does not exist on type 'never'.
|
||||
!!! error TS2339: The intersection 'mixB<typeof A>.(Anonymous class) & A' was reduced to 'never' because property 'pvt' exists in multiple constituents and is private in some.
|
||||
|
||||
abc.pb.toFixed();
|
||||
~~
|
||||
!!! error TS2339: Property 'pb' does not exist on type 'never'.
|
||||
!!! error TS2339: The intersection 'mixC<{ new (...args: any[]): mixB<typeof A>.(Anonymous class); prototype: mixB<any>.(Anonymous class); } & typeof A>.(Anonymous class) & mixB<typeof A>.(Anonymous class) & A' was reduced to 'never' because property 'pvt' exists in multiple constituents and is private in some.
|
||||
abc.ptd.toFixed(); // Error
|
||||
~~~
|
||||
!!! error TS2445: Property 'ptd' is protected and only accessible within class 'mixC<{ new (...args: any[]): mixB<typeof A>.(Anonymous class); prototype: mixB<any>.(Anonymous class); } & typeof A>.(Anonymous class) & mixB<typeof A>.(Anonymous class) & A' and its subclasses.
|
||||
!!! error TS2339: Property 'ptd' does not exist on type 'never'.
|
||||
!!! error TS2339: The intersection 'mixC<{ new (...args: any[]): mixB<typeof A>.(Anonymous class); prototype: mixB<any>.(Anonymous class); } & typeof A>.(Anonymous class) & mixB<typeof A>.(Anonymous class) & A' was reduced to 'never' because property 'pvt' exists in multiple constituents and is private in some.
|
||||
abc.pvt.toFixed(); // Error
|
||||
~~~
|
||||
!!! error TS2546: Property 'pvt' has conflicting declarations and is inaccessible in type 'mixC<{ new (...args: any[]): mixB<typeof A>.(Anonymous class); prototype: mixB<any>.(Anonymous class); } & typeof A>.(Anonymous class) & mixB<typeof A>.(Anonymous class) & A'.
|
||||
!!! error TS2339: Property 'pvt' does not exist on type 'never'.
|
||||
!!! error TS2339: The intersection 'mixC<{ new (...args: any[]): mixB<typeof A>.(Anonymous class); prototype: mixB<any>.(Anonymous class); } & typeof A>.(Anonymous class) & mixB<typeof A>.(Anonymous class) & A' was reduced to 'never' because property 'pvt' exists in multiple constituents and is private in some.
|
||||
|
||||
ab2c.pb.toFixed();
|
||||
~~
|
||||
!!! error TS2339: Property 'pb' does not exist on type 'never'.
|
||||
!!! error TS2339: The intersection 'mixC<{ new (...args: any[]): mixB2<typeof A>.(Anonymous class); prototype: mixB2<any>.(Anonymous class); } & typeof A>.(Anonymous class) & mixB2<typeof A>.(Anonymous class) & A' was reduced to 'never' because property 'pvt' exists in multiple constituents and is private in some.
|
||||
ab2c.ptd.toFixed(); // Error
|
||||
~~~
|
||||
!!! error TS2445: Property 'ptd' is protected and only accessible within class 'mixC<{ new (...args: any[]): mixB2<typeof A>.(Anonymous class); prototype: mixB2<any>.(Anonymous class); } & typeof A>.(Anonymous class) & mixB2<typeof A>.(Anonymous class) & A' and its subclasses.
|
||||
!!! error TS2339: Property 'ptd' does not exist on type 'never'.
|
||||
!!! error TS2339: The intersection 'mixC<{ new (...args: any[]): mixB2<typeof A>.(Anonymous class); prototype: mixB2<any>.(Anonymous class); } & typeof A>.(Anonymous class) & mixB2<typeof A>.(Anonymous class) & A' was reduced to 'never' because property 'pvt' exists in multiple constituents and is private in some.
|
||||
ab2c.pvt.toFixed(); // Error
|
||||
~~~
|
||||
!!! error TS2546: Property 'pvt' has conflicting declarations and is inaccessible in type 'mixC<{ new (...args: any[]): mixB2<typeof A>.(Anonymous class); prototype: mixB2<any>.(Anonymous class); } & typeof A>.(Anonymous class) & mixB2<typeof A>.(Anonymous class) & A'.
|
||||
!!! error TS2339: Property 'pvt' does not exist on type 'never'.
|
||||
!!! error TS2339: The intersection 'mixC<{ new (...args: any[]): mixB2<typeof A>.(Anonymous class); prototype: mixB2<any>.(Anonymous class); } & typeof A>.(Anonymous class) & mixB2<typeof A>.(Anonymous class) & A' was reduced to 'never' because property 'pvt' exists in multiple constituents and is private in some.
|
||||
|
||||
// Repro from #13924
|
||||
|
||||
|
||||
@ -136,67 +136,31 @@ a.pvt.toFixed(); // Error
|
||||
>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
ab.pb.toFixed();
|
||||
>ab.pb.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
|
||||
>ab.pb : Symbol(A.pb, Decl(mixinPrivateAndProtected.ts, 4, 9))
|
||||
>ab : Symbol(ab, Decl(mixinPrivateAndProtected.ts, 39, 16))
|
||||
>pb : Symbol(A.pb, Decl(mixinPrivateAndProtected.ts, 4, 9))
|
||||
>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
ab.ptd.toFixed(); // Error
|
||||
>ab.ptd.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
|
||||
>ab.ptd : Symbol(ptd, Decl(mixinPrivateAndProtected.ts, 11, 30), Decl(mixinPrivateAndProtected.ts, 5, 26))
|
||||
>ab : Symbol(ab, Decl(mixinPrivateAndProtected.ts, 39, 16))
|
||||
>ptd : Symbol(ptd, Decl(mixinPrivateAndProtected.ts, 11, 30), Decl(mixinPrivateAndProtected.ts, 5, 26))
|
||||
>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
ab.pvt.toFixed(); // Error
|
||||
>ab.pvt.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
|
||||
>ab.pvt : Symbol(pvt, Decl(mixinPrivateAndProtected.ts, 12, 35), Decl(mixinPrivateAndProtected.ts, 6, 30))
|
||||
>ab : Symbol(ab, Decl(mixinPrivateAndProtected.ts, 39, 16))
|
||||
>pvt : Symbol(pvt, Decl(mixinPrivateAndProtected.ts, 12, 35), Decl(mixinPrivateAndProtected.ts, 6, 30))
|
||||
>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
abc.pb.toFixed();
|
||||
>abc.pb.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
|
||||
>abc.pb : Symbol(A.pb, Decl(mixinPrivateAndProtected.ts, 4, 9))
|
||||
>abc : Symbol(abc, Decl(mixinPrivateAndProtected.ts, 40, 18))
|
||||
>pb : Symbol(A.pb, Decl(mixinPrivateAndProtected.ts, 4, 9))
|
||||
>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
abc.ptd.toFixed(); // Error
|
||||
>abc.ptd.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
|
||||
>abc.ptd : Symbol(ptd, Decl(mixinPrivateAndProtected.ts, 28, 30), Decl(mixinPrivateAndProtected.ts, 11, 30), Decl(mixinPrivateAndProtected.ts, 5, 26))
|
||||
>abc : Symbol(abc, Decl(mixinPrivateAndProtected.ts, 40, 18))
|
||||
>ptd : Symbol(ptd, Decl(mixinPrivateAndProtected.ts, 28, 30), Decl(mixinPrivateAndProtected.ts, 11, 30), Decl(mixinPrivateAndProtected.ts, 5, 26))
|
||||
>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
abc.pvt.toFixed(); // Error
|
||||
>abc.pvt.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
|
||||
>abc.pvt : Symbol(pvt, Decl(mixinPrivateAndProtected.ts, 29, 36), Decl(mixinPrivateAndProtected.ts, 12, 35), Decl(mixinPrivateAndProtected.ts, 6, 30))
|
||||
>abc : Symbol(abc, Decl(mixinPrivateAndProtected.ts, 40, 18))
|
||||
>pvt : Symbol(pvt, Decl(mixinPrivateAndProtected.ts, 29, 36), Decl(mixinPrivateAndProtected.ts, 12, 35), Decl(mixinPrivateAndProtected.ts, 6, 30))
|
||||
>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
ab2c.pb.toFixed();
|
||||
>ab2c.pb.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
|
||||
>ab2c.pb : Symbol(A.pb, Decl(mixinPrivateAndProtected.ts, 4, 9))
|
||||
>ab2c : Symbol(ab2c, Decl(mixinPrivateAndProtected.ts, 41, 20))
|
||||
>pb : Symbol(A.pb, Decl(mixinPrivateAndProtected.ts, 4, 9))
|
||||
>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
ab2c.ptd.toFixed(); // Error
|
||||
>ab2c.ptd.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
|
||||
>ab2c.ptd : Symbol(ptd, Decl(mixinPrivateAndProtected.ts, 28, 30), Decl(mixinPrivateAndProtected.ts, 18, 30), Decl(mixinPrivateAndProtected.ts, 5, 26))
|
||||
>ab2c : Symbol(ab2c, Decl(mixinPrivateAndProtected.ts, 41, 20))
|
||||
>ptd : Symbol(ptd, Decl(mixinPrivateAndProtected.ts, 28, 30), Decl(mixinPrivateAndProtected.ts, 18, 30), Decl(mixinPrivateAndProtected.ts, 5, 26))
|
||||
>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
ab2c.pvt.toFixed(); // Error
|
||||
>ab2c.pvt.toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
|
||||
>ab2c.pvt : Symbol(pvt, Decl(mixinPrivateAndProtected.ts, 29, 36), Decl(mixinPrivateAndProtected.ts, 6, 30))
|
||||
>ab2c : Symbol(ab2c, Decl(mixinPrivateAndProtected.ts, 41, 20))
|
||||
>pvt : Symbol(pvt, Decl(mixinPrivateAndProtected.ts, 29, 36), Decl(mixinPrivateAndProtected.ts, 6, 30))
|
||||
>toFixed : Symbol(Number.toFixed, Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
// Repro from #13924
|
||||
|
||||
|
||||
@ -107,18 +107,18 @@ const
|
||||
>A : typeof A
|
||||
|
||||
ab = new AB(),
|
||||
>ab : mixB<typeof A>.(Anonymous class) & A
|
||||
>new AB() : mixB<typeof A>.(Anonymous class) & A
|
||||
>ab : never
|
||||
>new AB() : never
|
||||
>AB : { new (...args: any[]): mixB<typeof A>.(Anonymous class); prototype: mixB<any>.(Anonymous class); } & typeof A
|
||||
|
||||
abc = new ABC(),
|
||||
>abc : mixC<{ new (...args: any[]): mixB<typeof A>.(Anonymous class); prototype: mixB<any>.(Anonymous class); } & typeof A>.(Anonymous class) & mixB<typeof A>.(Anonymous class) & A
|
||||
>new ABC() : mixC<{ new (...args: any[]): mixB<typeof A>.(Anonymous class); prototype: mixB<any>.(Anonymous class); } & typeof A>.(Anonymous class) & mixB<typeof A>.(Anonymous class) & A
|
||||
>abc : never
|
||||
>new ABC() : never
|
||||
>ABC : { new (...args: any[]): mixC<{ new (...args: any[]): mixB<typeof A>.(Anonymous class); prototype: mixB<any>.(Anonymous class); } & typeof A>.(Anonymous class); prototype: mixC<any>.(Anonymous class); } & { new (...args: any[]): mixB<typeof A>.(Anonymous class); prototype: mixB<any>.(Anonymous class); } & typeof A
|
||||
|
||||
ab2c = new AB2C();
|
||||
>ab2c : mixC<{ new (...args: any[]): mixB2<typeof A>.(Anonymous class); prototype: mixB2<any>.(Anonymous class); } & typeof A>.(Anonymous class) & mixB2<typeof A>.(Anonymous class) & A
|
||||
>new AB2C() : mixC<{ new (...args: any[]): mixB2<typeof A>.(Anonymous class); prototype: mixB2<any>.(Anonymous class); } & typeof A>.(Anonymous class) & mixB2<typeof A>.(Anonymous class) & A
|
||||
>ab2c : never
|
||||
>new AB2C() : never
|
||||
>AB2C : { new (...args: any[]): mixC<{ new (...args: any[]): mixB2<typeof A>.(Anonymous class); prototype: mixB2<any>.(Anonymous class); } & typeof A>.(Anonymous class); prototype: mixC<any>.(Anonymous class); } & { new (...args: any[]): mixB2<typeof A>.(Anonymous class); prototype: mixB2<any>.(Anonymous class); } & typeof A
|
||||
|
||||
a.pb.toFixed();
|
||||
@ -146,76 +146,76 @@ a.pvt.toFixed(); // Error
|
||||
>toFixed : (fractionDigits?: number) => string
|
||||
|
||||
ab.pb.toFixed();
|
||||
>ab.pb.toFixed() : string
|
||||
>ab.pb.toFixed : (fractionDigits?: number) => string
|
||||
>ab.pb : number
|
||||
>ab : mixB<typeof A>.(Anonymous class) & A
|
||||
>pb : number
|
||||
>toFixed : (fractionDigits?: number) => string
|
||||
>ab.pb.toFixed() : any
|
||||
>ab.pb.toFixed : any
|
||||
>ab.pb : any
|
||||
>ab : never
|
||||
>pb : any
|
||||
>toFixed : any
|
||||
|
||||
ab.ptd.toFixed(); // Error
|
||||
>ab.ptd.toFixed() : string
|
||||
>ab.ptd.toFixed : (fractionDigits?: number) => string
|
||||
>ab.ptd : number
|
||||
>ab : mixB<typeof A>.(Anonymous class) & A
|
||||
>ptd : number
|
||||
>toFixed : (fractionDigits?: number) => string
|
||||
>ab.ptd.toFixed() : any
|
||||
>ab.ptd.toFixed : any
|
||||
>ab.ptd : any
|
||||
>ab : never
|
||||
>ptd : any
|
||||
>toFixed : any
|
||||
|
||||
ab.pvt.toFixed(); // Error
|
||||
>ab.pvt.toFixed() : string
|
||||
>ab.pvt.toFixed : (fractionDigits?: number) => string
|
||||
>ab.pvt : number
|
||||
>ab : mixB<typeof A>.(Anonymous class) & A
|
||||
>pvt : number
|
||||
>toFixed : (fractionDigits?: number) => string
|
||||
>ab.pvt.toFixed() : any
|
||||
>ab.pvt.toFixed : any
|
||||
>ab.pvt : any
|
||||
>ab : never
|
||||
>pvt : any
|
||||
>toFixed : any
|
||||
|
||||
abc.pb.toFixed();
|
||||
>abc.pb.toFixed() : string
|
||||
>abc.pb.toFixed : (fractionDigits?: number) => string
|
||||
>abc.pb : number
|
||||
>abc : mixC<{ new (...args: any[]): mixB<typeof A>.(Anonymous class); prototype: mixB<any>.(Anonymous class); } & typeof A>.(Anonymous class) & mixB<typeof A>.(Anonymous class) & A
|
||||
>pb : number
|
||||
>toFixed : (fractionDigits?: number) => string
|
||||
>abc.pb.toFixed() : any
|
||||
>abc.pb.toFixed : any
|
||||
>abc.pb : any
|
||||
>abc : never
|
||||
>pb : any
|
||||
>toFixed : any
|
||||
|
||||
abc.ptd.toFixed(); // Error
|
||||
>abc.ptd.toFixed() : string
|
||||
>abc.ptd.toFixed : (fractionDigits?: number) => string
|
||||
>abc.ptd : number
|
||||
>abc : mixC<{ new (...args: any[]): mixB<typeof A>.(Anonymous class); prototype: mixB<any>.(Anonymous class); } & typeof A>.(Anonymous class) & mixB<typeof A>.(Anonymous class) & A
|
||||
>ptd : number
|
||||
>toFixed : (fractionDigits?: number) => string
|
||||
>abc.ptd.toFixed() : any
|
||||
>abc.ptd.toFixed : any
|
||||
>abc.ptd : any
|
||||
>abc : never
|
||||
>ptd : any
|
||||
>toFixed : any
|
||||
|
||||
abc.pvt.toFixed(); // Error
|
||||
>abc.pvt.toFixed() : string
|
||||
>abc.pvt.toFixed : (fractionDigits?: number) => string
|
||||
>abc.pvt : number
|
||||
>abc : mixC<{ new (...args: any[]): mixB<typeof A>.(Anonymous class); prototype: mixB<any>.(Anonymous class); } & typeof A>.(Anonymous class) & mixB<typeof A>.(Anonymous class) & A
|
||||
>pvt : number
|
||||
>toFixed : (fractionDigits?: number) => string
|
||||
>abc.pvt.toFixed() : any
|
||||
>abc.pvt.toFixed : any
|
||||
>abc.pvt : any
|
||||
>abc : never
|
||||
>pvt : any
|
||||
>toFixed : any
|
||||
|
||||
ab2c.pb.toFixed();
|
||||
>ab2c.pb.toFixed() : string
|
||||
>ab2c.pb.toFixed : (fractionDigits?: number) => string
|
||||
>ab2c.pb : number
|
||||
>ab2c : mixC<{ new (...args: any[]): mixB2<typeof A>.(Anonymous class); prototype: mixB2<any>.(Anonymous class); } & typeof A>.(Anonymous class) & mixB2<typeof A>.(Anonymous class) & A
|
||||
>pb : number
|
||||
>toFixed : (fractionDigits?: number) => string
|
||||
>ab2c.pb.toFixed() : any
|
||||
>ab2c.pb.toFixed : any
|
||||
>ab2c.pb : any
|
||||
>ab2c : never
|
||||
>pb : any
|
||||
>toFixed : any
|
||||
|
||||
ab2c.ptd.toFixed(); // Error
|
||||
>ab2c.ptd.toFixed() : string
|
||||
>ab2c.ptd.toFixed : (fractionDigits?: number) => string
|
||||
>ab2c.ptd : number
|
||||
>ab2c : mixC<{ new (...args: any[]): mixB2<typeof A>.(Anonymous class); prototype: mixB2<any>.(Anonymous class); } & typeof A>.(Anonymous class) & mixB2<typeof A>.(Anonymous class) & A
|
||||
>ptd : number
|
||||
>toFixed : (fractionDigits?: number) => string
|
||||
>ab2c.ptd.toFixed() : any
|
||||
>ab2c.ptd.toFixed : any
|
||||
>ab2c.ptd : any
|
||||
>ab2c : never
|
||||
>ptd : any
|
||||
>toFixed : any
|
||||
|
||||
ab2c.pvt.toFixed(); // Error
|
||||
>ab2c.pvt.toFixed() : string
|
||||
>ab2c.pvt.toFixed : (fractionDigits?: number) => string
|
||||
>ab2c.pvt : number
|
||||
>ab2c : mixC<{ new (...args: any[]): mixB2<typeof A>.(Anonymous class); prototype: mixB2<any>.(Anonymous class); } & typeof A>.(Anonymous class) & mixB2<typeof A>.(Anonymous class) & A
|
||||
>pvt : number
|
||||
>toFixed : (fractionDigits?: number) => string
|
||||
>ab2c.pvt.toFixed() : any
|
||||
>ab2c.pvt.toFixed : any
|
||||
>ab2c.pvt : any
|
||||
>ab2c : never
|
||||
>pvt : any
|
||||
>toFixed : any
|
||||
|
||||
// Repro from #13924
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOf.ts(7,20): error TS2339: Property 'global' does not exist on type 'never'.
|
||||
The intersection 'I & RegExp' was reduced to 'never' because property 'global' has conflicting types in some constituents.
|
||||
|
||||
|
||||
==== tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOf.ts (1 errors) ====
|
||||
@ -11,4 +12,5 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOf.ts(7,20)
|
||||
} else if (!result.global) {
|
||||
~~~~~~
|
||||
!!! error TS2339: Property 'global' does not exist on type 'never'.
|
||||
!!! error TS2339: The intersection 'I & RegExp' was reduced to 'never' because property 'global' has conflicting types in some constituents.
|
||||
}
|
||||
59
tests/cases/compiler/intersectionWithConflictingPrivates.ts
Normal file
59
tests/cases/compiler/intersectionWithConflictingPrivates.ts
Normal file
@ -0,0 +1,59 @@
|
||||
// @strict: true
|
||||
// @target: esnext
|
||||
|
||||
class A { private x: unknown; y?: string; }
|
||||
class B { private x: unknown; y?: string; }
|
||||
|
||||
declare let ab: A & B;
|
||||
ab.y = 'hello';
|
||||
ab = {};
|
||||
|
||||
function f1(node: A | B) {
|
||||
if (node instanceof A || node instanceof A) {
|
||||
node; // A
|
||||
}
|
||||
else {
|
||||
node; // B
|
||||
}
|
||||
node; // A | B
|
||||
}
|
||||
|
||||
// Repro from #37659
|
||||
|
||||
abstract class ViewNode { }
|
||||
abstract class ViewRefNode extends ViewNode { }
|
||||
abstract class ViewRefFileNode extends ViewRefNode { }
|
||||
|
||||
class CommitFileNode extends ViewRefFileNode {
|
||||
private _id: any;
|
||||
}
|
||||
|
||||
class ResultsFileNode extends ViewRefFileNode {
|
||||
private _id: any;
|
||||
}
|
||||
|
||||
class StashFileNode extends CommitFileNode {
|
||||
private _id2: any;
|
||||
}
|
||||
|
||||
class StatusFileNode extends ViewNode {
|
||||
private _id: any;
|
||||
}
|
||||
|
||||
class Foo {
|
||||
private async foo(node: CommitFileNode | ResultsFileNode | StashFileNode) {
|
||||
if (
|
||||
!(node instanceof CommitFileNode) &&
|
||||
!(node instanceof StashFileNode) &&
|
||||
!(node instanceof ResultsFileNode)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
await this.bar(node);
|
||||
}
|
||||
|
||||
private async bar(node: CommitFileNode | ResultsFileNode | StashFileNode | StatusFileNode, options?: {}) {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user