Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -4212,7 +4212,7 @@
"category": "Error",
"code": 4092
},
"Property '{0}' of exported class expression may not be private or protected.": {
"Property '{0}' of exported anonymous class type may not be private or protected.": {
"category": "Error",
"code": 4094
},
Expand Down
5 changes: 4 additions & 1 deletion src/compiler/transformers/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,10 @@ export function transformDeclarations(context: TransformationContext) {
function reportPrivateInBaseOfClassExpression(propertyName: string) {
if (errorNameNode || errorFallbackNode) {
context.addDiagnostic(
createDiagnosticForNode((errorNameNode || errorFallbackNode)!, Diagnostics.Property_0_of_exported_class_expression_may_not_be_private_or_protected, propertyName),
addRelatedInfo(
createDiagnosticForNode((errorNameNode || errorFallbackNode)!, Diagnostics.Property_0_of_exported_anonymous_class_type_may_not_be_private_or_protected, propertyName),
...(isVariableDeclaration((errorNameNode || errorFallbackNode)!.parent) ? [createDiagnosticForNode((errorNameNode || errorFallbackNode)!, Diagnostics.Add_a_type_annotation_to_the_variable_0, errorDeclarationNameWithFallback())] : []),
),
);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
another.ts(11,1): error TS4094: Property '_assertIsStripped' of exported class expression may not be private or protected.
another.ts(11,1): error TS4094: Property '_onDispose' of exported class expression may not be private or protected.
first.ts(12,1): error TS4094: Property '_assertIsStripped' of exported class expression may not be private or protected.
first.ts(12,1): error TS4094: Property '_onDispose' of exported class expression may not be private or protected.
first.ts(13,14): error TS4094: Property '_assertIsStripped' of exported class expression may not be private or protected.
first.ts(13,14): error TS4094: Property '_onDispose' of exported class expression may not be private or protected.
another.ts(11,1): error TS4094: Property '_assertIsStripped' of exported anonymous class type may not be private or protected.
another.ts(11,1): error TS4094: Property '_onDispose' of exported anonymous class type may not be private or protected.
first.ts(12,1): error TS4094: Property '_assertIsStripped' of exported anonymous class type may not be private or protected.
first.ts(12,1): error TS4094: Property '_onDispose' of exported anonymous class type may not be private or protected.
first.ts(13,14): error TS4094: Property '_assertIsStripped' of exported anonymous class type may not be private or protected.
first.ts(13,14): error TS4094: Property '_onDispose' of exported anonymous class type may not be private or protected.


==== first.ts (4 errors) ====
Expand All @@ -20,14 +20,14 @@ first.ts(13,14): error TS4094: Property '_onDispose' of exported class expressio
// No error, but definition is wrong.
export default mix(DisposableMixin);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS4094: Property '_assertIsStripped' of exported class expression may not be private or protected.
!!! error TS4094: Property '_assertIsStripped' of exported anonymous class type may not be private or protected.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS4094: Property '_onDispose' of exported class expression may not be private or protected.
!!! error TS4094: Property '_onDispose' of exported anonymous class type may not be private or protected.
export class Monitor extends mix(DisposableMixin) {
~~~~~~~
!!! error TS4094: Property '_assertIsStripped' of exported class expression may not be private or protected.
!!! error TS4094: Property '_assertIsStripped' of exported anonymous class type may not be private or protected.
~~~~~~~
!!! error TS4094: Property '_onDispose' of exported class expression may not be private or protected.
!!! error TS4094: Property '_onDispose' of exported anonymous class type may not be private or protected.
protected _onDispose() {
}
}
Expand All @@ -45,9 +45,9 @@ first.ts(13,14): error TS4094: Property '_onDispose' of exported class expressio

export default class extends mix(DisposableMixin) {
~~~~~~
!!! error TS4094: Property '_assertIsStripped' of exported class expression may not be private or protected.
!!! error TS4094: Property '_assertIsStripped' of exported anonymous class type may not be private or protected.
~~~~~~
!!! error TS4094: Property '_onDispose' of exported class expression may not be private or protected.
!!! error TS4094: Property '_onDispose' of exported anonymous class type may not be private or protected.
protected _onDispose() {
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
emitClassExpressionInDeclarationFile2.ts(1,12): error TS4094: Property 'p' of exported class expression may not be private or protected.
emitClassExpressionInDeclarationFile2.ts(1,12): error TS4094: Property 'ps' of exported class expression may not be private or protected.
emitClassExpressionInDeclarationFile2.ts(16,17): error TS4094: Property 'property' of exported class expression may not be private or protected.
emitClassExpressionInDeclarationFile2.ts(23,14): error TS4094: Property 'property' of exported class expression may not be private or protected.
emitClassExpressionInDeclarationFile2.ts(1,12): error TS4094: Property 'p' of exported anonymous class type may not be private or protected.
emitClassExpressionInDeclarationFile2.ts(1,12): error TS4094: Property 'ps' of exported anonymous class type may not be private or protected.
emitClassExpressionInDeclarationFile2.ts(16,17): error TS4094: Property 'property' of exported anonymous class type may not be private or protected.
emitClassExpressionInDeclarationFile2.ts(23,14): error TS4094: Property 'property' of exported anonymous class type may not be private or protected.


==== emitClassExpressionInDeclarationFile2.ts (4 errors) ====
export var noPrivates = class {
~~~~~~~~~~
!!! error TS4094: Property 'p' of exported class expression may not be private or protected.
!!! error TS4094: Property 'p' of exported anonymous class type may not be private or protected.
!!! related TS9027 emitClassExpressionInDeclarationFile2.ts:1:12: Add a type annotation to the variable noPrivates.
~~~~~~~~~~
!!! error TS4094: Property 'ps' of exported class expression may not be private or protected.
!!! error TS4094: Property 'ps' of exported anonymous class type may not be private or protected.
!!! related TS9027 emitClassExpressionInDeclarationFile2.ts:1:12: Add a type annotation to the variable noPrivates.
static getTags() { }
tags() { }
private static ps = -1
Expand All @@ -26,7 +28,7 @@ emitClassExpressionInDeclarationFile2.ts(23,14): error TS4094: Property 'propert
export type Constructor<T> = new(...args: any[]) => T;
export function WithTags<T extends Constructor<FooItem>>(Base: T) {
~~~~~~~~
!!! error TS4094: Property 'property' of exported class expression may not be private or protected.
!!! error TS4094: Property 'property' of exported anonymous class type may not be private or protected.
return class extends Base {
static getTags(): void { }
tags(): void { }
Expand All @@ -35,7 +37,7 @@ emitClassExpressionInDeclarationFile2.ts(23,14): error TS4094: Property 'propert

export class Test extends WithTags(FooItem) {}
~~~~
!!! error TS4094: Property 'property' of exported class expression may not be private or protected.
!!! error TS4094: Property 'property' of exported anonymous class type may not be private or protected.

const test = new Test();

Expand Down
Loading