diff --git a/internal/ast/ast.go b/internal/ast/ast.go index 2a4de4ecda..bd8de3b669 100644 --- a/internal/ast/ast.go +++ b/internal/ast/ast.go @@ -233,6 +233,11 @@ func (n *Node) TemplateLiteralLikeData() *TemplateLiteralLikeBase { return n.data.TemplateLiteralLikeData() } +type mutableNode Node + +func (n *Node) AsMutable() *mutableNode { return (*mutableNode)(n) } +func (n *mutableNode) SetModifiers(modifiers *ModifierList) { n.data.setModifiers(modifiers) } + func (n *Node) Symbol() *Symbol { data := n.DeclarationData() if data != nil { @@ -1633,6 +1638,7 @@ type nodeData interface { Clone(v NodeFactoryCoercible) *Node Name() *DeclarationName Modifiers() *ModifierList + setModifiers(modifiers *ModifierList) FlowNodeData() *FlowNodeBase DeclarationData() *DeclarationBase ExportableData() *ExportableBase @@ -1660,6 +1666,7 @@ func (node *NodeDefault) VisitEachChild(v *NodeVisitor) *Node { re func (node *NodeDefault) Clone(v NodeFactoryCoercible) *Node { return nil } func (node *NodeDefault) Name() *DeclarationName { return nil } func (node *NodeDefault) Modifiers() *ModifierList { return nil } +func (node *NodeDefault) setModifiers(modifiers *ModifierList) {} func (node *NodeDefault) FlowNodeData() *FlowNodeBase { return nil } func (node *NodeDefault) DeclarationData() *DeclarationBase { return nil } func (node *NodeDefault) ExportableData() *ExportableBase { return nil } @@ -4761,9 +4768,10 @@ type NamedMemberBase struct { PostfixToken *TokenNode // TokenNode. Optional } -func (node *NamedMemberBase) DeclarationData() *DeclarationBase { return &node.DeclarationBase } -func (node *NamedMemberBase) Modifiers() *ModifierList { return node.modifiers } -func (node *NamedMemberBase) Name() *DeclarationName { return node.name } +func (node *NamedMemberBase) DeclarationData() *DeclarationBase { return &node.DeclarationBase } +func (node *NamedMemberBase) Modifiers() *ModifierList { return node.modifiers } +func (node *NamedMemberBase) setModifiers(modifiers *ModifierList) { node.modifiers = modifiers } +func (node *NamedMemberBase) Name() *DeclarationName { return node.name } // CallSignatureDeclaration diff --git a/internal/checker/grammarchecks.go b/internal/checker/grammarchecks.go index 3a6363e567..6b19f293b3 100644 --- a/internal/checker/grammarchecks.go +++ b/internal/checker/grammarchecks.go @@ -307,11 +307,11 @@ func (c *Checker) checkGrammarModifiers(node *ast.Node /*Union[HasModifiers, Has return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_already_seen, "override") } else if flags&ast.ModifierFlagsAmbient != 0 { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_cannot_be_used_with_1_modifier, "override", "declare") - } else if flags&ast.ModifierFlagsReadonly != 0 { + } else if flags&ast.ModifierFlagsReadonly != 0 && modifier.Flags&ast.NodeFlagsReparsed == 0 { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_must_precede_1_modifier, "override", "readonly") - } else if flags&ast.ModifierFlagsAccessor != 0 { + } else if flags&ast.ModifierFlagsAccessor != 0 && modifier.Flags&ast.NodeFlagsReparsed == 0 { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_must_precede_1_modifier, "override", "accessor") - } else if flags&ast.ModifierFlagsAsync != 0 { + } else if flags&ast.ModifierFlagsAsync != 0 && modifier.Flags&ast.NodeFlagsReparsed == 0 { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_must_precede_1_modifier, "override", "async") } flags |= ast.ModifierFlagsOverride @@ -324,22 +324,22 @@ func (c *Checker) checkGrammarModifiers(node *ast.Node /*Union[HasModifiers, Has if flags&ast.ModifierFlagsAccessibilityModifier != 0 { return c.grammarErrorOnNode(modifier, diagnostics.Accessibility_modifier_already_seen) - } else if flags&ast.ModifierFlagsOverride != 0 { + } else if flags&ast.ModifierFlagsOverride != 0 && modifier.Flags&ast.NodeFlagsReparsed == 0 { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_must_precede_1_modifier, text, "override") - } else if flags&ast.ModifierFlagsStatic != 0 { + } else if flags&ast.ModifierFlagsStatic != 0 && modifier.Flags&ast.NodeFlagsReparsed == 0 { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_must_precede_1_modifier, text, "static") - } else if flags&ast.ModifierFlagsAccessor != 0 { + } else if flags&ast.ModifierFlagsAccessor != 0 && modifier.Flags&ast.NodeFlagsReparsed == 0 { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_must_precede_1_modifier, text, "accessor") - } else if flags&ast.ModifierFlagsReadonly != 0 { + } else if flags&ast.ModifierFlagsReadonly != 0 && modifier.Flags&ast.NodeFlagsReparsed == 0 { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_must_precede_1_modifier, text, "readonly") - } else if flags&ast.ModifierFlagsAsync != 0 { + } else if flags&ast.ModifierFlagsAsync != 0 && modifier.Flags&ast.NodeFlagsReparsed == 0 { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_must_precede_1_modifier, text, "async") } else if node.Parent.Kind == ast.KindModuleBlock || node.Parent.Kind == ast.KindSourceFile { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_cannot_appear_on_a_module_or_namespace_element, text) } else if flags&ast.ModifierFlagsAbstract != 0 { if modifier.Kind == ast.KindPrivateKeyword { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_cannot_be_used_with_1_modifier, text, "abstract") - } else { + } else if modifier.Flags&ast.NodeFlagsReparsed == 0 { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_must_precede_1_modifier, text, "abstract") } } else if ast.IsPrivateIdentifierClassElementDeclaration(node) { @@ -349,11 +349,11 @@ func (c *Checker) checkGrammarModifiers(node *ast.Node /*Union[HasModifiers, Has case ast.KindStaticKeyword: if flags&ast.ModifierFlagsStatic != 0 { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_already_seen, "static") - } else if flags&ast.ModifierFlagsReadonly != 0 { + } else if flags&ast.ModifierFlagsReadonly != 0 && modifier.Flags&ast.NodeFlagsReparsed == 0 { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_must_precede_1_modifier, "static", "readonly") - } else if flags&ast.ModifierFlagsAsync != 0 { + } else if flags&ast.ModifierFlagsAsync != 0 && modifier.Flags&ast.NodeFlagsReparsed == 0 { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_must_precede_1_modifier, "static", "async") - } else if flags&ast.ModifierFlagsAccessor != 0 { + } else if flags&ast.ModifierFlagsAccessor != 0 && modifier.Flags&ast.NodeFlagsReparsed == 0 { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_must_precede_1_modifier, "static", "accessor") } else if node.Parent.Kind == ast.KindModuleBlock || node.Parent.Kind == ast.KindSourceFile { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_cannot_appear_on_a_module_or_namespace_element, "static") @@ -361,7 +361,7 @@ func (c *Checker) checkGrammarModifiers(node *ast.Node /*Union[HasModifiers, Has return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_cannot_appear_on_a_parameter, "static") } else if flags&ast.ModifierFlagsAbstract != 0 { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_cannot_be_used_with_1_modifier, "static", "abstract") - } else if flags&ast.ModifierFlagsOverride != 0 { + } else if flags&ast.ModifierFlagsOverride != 0 && modifier.Flags&ast.NodeFlagsReparsed == 0 { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_must_precede_1_modifier, "static", "override") } flags |= ast.ModifierFlagsStatic @@ -394,11 +394,11 @@ func (c *Checker) checkGrammarModifiers(node *ast.Node /*Union[HasModifiers, Has } if flags&ast.ModifierFlagsExport != 0 { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_already_seen, "export") - } else if flags&ast.ModifierFlagsAmbient != 0 { + } else if flags&ast.ModifierFlagsAmbient != 0 && modifier.Flags&ast.NodeFlagsReparsed == 0 { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_must_precede_1_modifier, "export", "declare") - } else if flags&ast.ModifierFlagsAbstract != 0 { + } else if flags&ast.ModifierFlagsAbstract != 0 && modifier.Flags&ast.NodeFlagsReparsed == 0 { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_must_precede_1_modifier, "export", "abstract") - } else if flags&ast.ModifierFlagsAsync != 0 { + } else if flags&ast.ModifierFlagsAsync != 0 && modifier.Flags&ast.NodeFlagsReparsed == 0 { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_must_precede_1_modifier, "export", "async") } else if ast.IsClassLike(node.Parent) && !ast.IsJSTypeAliasDeclaration(node) { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_cannot_appear_on_class_elements_of_this_kind, "export") @@ -423,7 +423,7 @@ func (c *Checker) checkGrammarModifiers(node *ast.Node /*Union[HasModifiers, Has return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_cannot_appear_on_a_using_declaration, "default") } else if blockScopeKind == ast.NodeFlagsAwaitUsing { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_cannot_appear_on_an_await_using_declaration, "default") - } else if flags&ast.ModifierFlagsExport == 0 { + } else if flags&ast.ModifierFlagsExport == 0 && modifier.Flags&ast.NodeFlagsReparsed == 0 { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_must_precede_1_modifier, "export", "default") } else if sawExportBeforeDecorators { return c.grammarErrorOnNode(firstDecorator, diagnostics.Decorators_are_not_valid_here) @@ -480,10 +480,10 @@ func (c *Checker) checkGrammarModifiers(node *ast.Node /*Union[HasModifiers, Has if flags&ast.ModifierFlagsAsync != 0 && lastAsync != nil { return c.grammarErrorOnNode(lastAsync, diagnostics.X_0_modifier_cannot_be_used_with_1_modifier, "async", "abstract") } - if flags&ast.ModifierFlagsOverride != 0 { + if flags&ast.ModifierFlagsOverride != 0 && modifier.Flags&ast.NodeFlagsReparsed == 0 { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_must_precede_1_modifier, "abstract", "override") } - if flags&ast.ModifierFlagsAccessor != 0 { + if flags&ast.ModifierFlagsAccessor != 0 && modifier.Flags&ast.NodeFlagsReparsed == 0 { return c.grammarErrorOnNode(modifier, diagnostics.X_0_modifier_must_precede_1_modifier, "abstract", "accessor") } } diff --git a/internal/parser/reparser.go b/internal/parser/reparser.go index 041fd45f76..ff0676c91b 100644 --- a/internal/parser/reparser.go +++ b/internal/parser/reparser.go @@ -105,39 +105,43 @@ func (p *Parser) reparseTags(parent *ast.Node, jsDoc []*ast.Node) { } switch tag.Kind { case ast.KindJSDocTypeTag: - if parent.Kind == ast.KindVariableStatement && parent.AsVariableStatement().DeclarationList != nil { - for _, declaration := range parent.AsVariableStatement().DeclarationList.AsVariableDeclarationList().Declarations.Nodes { - if declaration.AsVariableDeclaration().Type == nil { - declaration.AsVariableDeclaration().Type = p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, declaration) - break + switch parent.Kind { + case ast.KindVariableStatement: + if parent.AsVariableStatement().DeclarationList != nil { + for _, declaration := range parent.AsVariableStatement().DeclarationList.AsVariableDeclarationList().Declarations.Nodes { + if declaration.AsVariableDeclaration().Type == nil { + declaration.AsVariableDeclaration().Type = p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, declaration) + break + } } } - } else if parent.Kind == ast.KindVariableDeclaration { + case ast.KindVariableDeclaration: if parent.AsVariableDeclaration().Type == nil { parent.AsVariableDeclaration().Type = p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, parent) } - } else if parent.Kind == ast.KindPropertyDeclaration { + case ast.KindPropertyDeclaration: declaration := parent.AsPropertyDeclaration() if declaration.Type == nil { declaration.Type = p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, parent) } - } else if parent.Kind == ast.KindPropertyAssignment { + case ast.KindPropertyAssignment: prop := parent.AsPropertyAssignment() prop.Initializer = p.makeNewTypeAssertion(p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, nil), prop.Initializer) - } else if parent.Kind == ast.KindExportAssignment { + case ast.KindExportAssignment: export := parent.AsExportAssignment() export.Expression = p.makeNewTypeAssertion(p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, nil), export.Expression) - } else if parent.Kind == ast.KindReturnStatement { + case ast.KindReturnStatement: ret := parent.AsReturnStatement() ret.Expression = p.makeNewTypeAssertion(p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, nil), ret.Expression) - } else if parent.Kind == ast.KindParenthesizedExpression { + case ast.KindParenthesizedExpression: paren := parent.AsParenthesizedExpression() paren.Expression = p.makeNewTypeAssertion(p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, nil), paren.Expression) - } else if parent.Kind == ast.KindExpressionStatement && - parent.AsExpressionStatement().Expression.Kind == ast.KindBinaryExpression { - bin := parent.AsExpressionStatement().Expression.AsBinaryExpression() - if ast.GetAssignmentDeclarationKind(bin) != ast.JSDeclarationKindNone { - bin.Right = p.makeNewTypeAssertion(p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, nil), bin.Right) + case ast.KindExpressionStatement: + if parent.AsExpressionStatement().Expression.Kind == ast.KindBinaryExpression { + bin := parent.AsExpressionStatement().Expression.AsBinaryExpression() + if ast.GetAssignmentDeclarationKind(bin) != ast.JSDeclarationKindNone { + bin.Right = p.makeNewTypeAssertion(p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, nil), bin.Right) + } } } case ast.KindJSDocTemplateTag: @@ -178,6 +182,39 @@ func (p *Parser) reparseTags(parent *ast.Node, jsDoc []*ast.Node) { fun.FunctionLikeData().Type = p.makeNewType(tag.AsJSDocReturnTag().TypeExpression, fun) } } + case ast.KindJSDocReadonlyTag, ast.KindJSDocPrivateTag, ast.KindJSDocPublicTag, ast.KindJSDocProtectedTag, ast.KindJSDocOverrideTag: + switch parent.Kind { + case ast.KindPropertyDeclaration, ast.KindMethodDeclaration, ast.KindGetAccessor, ast.KindSetAccessor: + // !!! BinaryExpression (this.p assignments) + var keyword ast.Kind + switch tag.Kind { + case ast.KindJSDocReadonlyTag: + keyword = ast.KindReadonlyKeyword + case ast.KindJSDocPrivateTag: + keyword = ast.KindPrivateKeyword + case ast.KindJSDocPublicTag: + keyword = ast.KindPublicKeyword + case ast.KindJSDocProtectedTag: + keyword = ast.KindProtectedKeyword + case ast.KindJSDocOverrideTag: + keyword = ast.KindOverrideKeyword + } + modifier := p.factory.NewModifier(keyword) + modifier.Loc = tag.Loc + modifier.Flags = p.contextFlags | ast.NodeFlagsReparsed + var nodes []*ast.Node + var loc core.TextRange + if parent.Modifiers() == nil { + nodes = p.nodeSlicePool.NewSlice(1) + nodes[0] = modifier + loc = tag.Loc + } else { + nodes = append(parent.Modifiers().Nodes, modifier) + loc = parent.Modifiers().Loc + } + parent.AsMutable().SetModifiers(p.newModifierList(loc, nodes)) + } + // !!! @extends, @implements, @this, @satisfies } } } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocAccessibilityTags.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocAccessibilityTags.errors.txt new file mode 100644 index 0000000000..d1ecb43984 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocAccessibilityTags.errors.txt @@ -0,0 +1,80 @@ +jsdocAccessibilityTag.js(50,14): error TS2341: Property 'priv' is private and only accessible within class 'A'. +jsdocAccessibilityTag.js(58,9): error TS2341: Property 'priv' is private and only accessible within class 'A'. +jsdocAccessibilityTag.js(58,24): error TS2445: Property 'prot' is protected and only accessible within class 'A' and its subclasses. +jsdocAccessibilityTag.js(59,9): error TS2341: Property 'priv' is private and only accessible within class 'A'. +jsdocAccessibilityTag.js(59,24): error TS2445: Property 'prot' is protected and only accessible within class 'A' and its subclasses. + + +==== jsdocAccessibilityTag.js (5 errors) ==== + class A { + /** + * Ap docs + * + * @private + */ + priv = 4; + /** + * Aq docs + * + * @protected + */ + prot = 5; + /** + * Ar docs + * + * @public + */ + pub = 6; + /** @public */ + get ack() { return this.priv } + /** @private */ + set ack(value) { } + } + class C { + constructor() { + /** + * Cp docs + * + * @private + */ + this.priv2 = 1; + /** + * Cq docs + * + * @protected + */ + this.prot2 = 2; + /** + * Cr docs + * + * @public + */ + this.pub2 = 3; + } + h() { return this.priv2 } + } + class B extends A { + m() { + this.priv + this.prot + this.pub + ~~~~ +!!! error TS2341: Property 'priv' is private and only accessible within class 'A'. + } + } + class D extends C { + n() { + this.priv2 + this.prot2 + this.pub2 + } + } + new A().priv + new A().prot + new A().pub + ~~~~ +!!! error TS2341: Property 'priv' is private and only accessible within class 'A'. + ~~~~ +!!! error TS2445: Property 'prot' is protected and only accessible within class 'A' and its subclasses. + new B().priv + new B().prot + new B().pub + ~~~~ +!!! error TS2341: Property 'priv' is private and only accessible within class 'A'. + ~~~~ +!!! error TS2445: Property 'prot' is protected and only accessible within class 'A' and its subclasses. + new C().priv2 + new C().prot2 + new C().pub2 + new D().priv2 + new D().prot2 + new D().pub2 + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocOverrideTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocOverrideTag1.errors.txt index 133bf9dbd2..b3971c3201 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocOverrideTag1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocOverrideTag1.errors.txt @@ -1,8 +1,9 @@ -0.js(23,5): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'A'. 0.js(27,5): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'A'. +0.js(32,5): error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'A'. +0.js(40,5): error TS4112: This member cannot have an 'override' modifier because its containing class 'C' does not extend another class. -==== 0.js (2 errors) ==== +==== 0.js (3 errors) ==== class A { /** @@ -26,8 +27,6 @@ * @returns {boolean} */ foo (a) { - ~~~ -!!! error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'A'. return super.foo(a) } @@ -39,6 +38,8 @@ /** @override */ baz () { + ~~~ +!!! error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'A'. } } @@ -47,6 +48,8 @@ class C { /** @override */ foo () { + ~~~ +!!! error TS4112: This member cannot have an 'override' modifier because its containing class 'C' does not extend another class. } } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocReadonly.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocReadonly.errors.txt new file mode 100644 index 0000000000..3cce555727 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocReadonly.errors.txt @@ -0,0 +1,30 @@ +jsdocReadonly.js(23,3): error TS2540: Cannot assign to 'y' because it is a read-only property. + + +==== jsdocReadonly.js (1 errors) ==== + class LOL { + /** + * @readonly + * @private + * @type {number} + * Order rules do not apply to JSDoc + */ + x = 1 + /** @readonly */ + y = 2 + /** @readonly Definitely not here */ + static z = 3 + /** @readonly This is OK too */ + constructor() { + /** ok */ + this.y = 2 + /** @readonly ok */ + this.ka = 2 + } + } + + var l = new LOL() + l.y = 12 + ~ +!!! error TS2540: Cannot assign to 'y' because it is a read-only property. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocReadonly.types b/testdata/baselines/reference/submodule/conformance/jsdocReadonly.types index 066dd4947c..843b44c0cd 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocReadonly.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocReadonly.types @@ -16,12 +16,12 @@ class LOL { /** @readonly */ y = 2 ->y : number +>y : 2 >2 : 2 /** @readonly Definitely not here */ static z = 3 ->z : number +>z : 3 >3 : 3 /** @readonly This is OK too */ @@ -29,9 +29,9 @@ class LOL { /** ok */ this.y = 2 >this.y = 2 : 2 ->this.y : number +>this.y : 2 >this : this ->y : number +>y : 2 >2 : 2 /** @readonly ok */ @@ -51,8 +51,8 @@ var l = new LOL() l.y = 12 >l.y = 12 : 12 ->l.y : number +>l.y : any >l : LOL ->y : number +>y : any >12 : 12 diff --git a/testdata/baselines/reference/submodule/conformance/jsdocReadonlyDeclarations.types b/testdata/baselines/reference/submodule/conformance/jsdocReadonlyDeclarations.types index f66781d6a4..f62c95121d 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocReadonlyDeclarations.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocReadonlyDeclarations.types @@ -6,7 +6,7 @@ class C { /** @readonly */ x = 6 ->x : number +>x : 6 >6 : 6 /** @readonly */ @@ -15,9 +15,9 @@ class C { this.x = n >this.x = n : any ->this.x : number +>this.x : 6 >this : this ->x : number +>x : 6 >n : any /** @@ -34,10 +34,10 @@ class C { } } new C().x ->new C().x : number +>new C().x : 6 >new C() : C >C : typeof C ->x : number +>x : 6 function F() { >F : () => void diff --git a/testdata/baselines/reference/submodule/conformance/override_js1.errors.txt b/testdata/baselines/reference/submodule/conformance/override_js1.errors.txt index 79b3b91719..65618f3449 100644 --- a/testdata/baselines/reference/submodule/conformance/override_js1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/override_js1.errors.txt @@ -1,8 +1,10 @@ a.js(7,5): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'. -a.js(9,5): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'. +a.js(11,5): error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'B'. +a.js(17,5): error TS4112: This member cannot have an 'override' modifier because its containing class 'C' does not extend another class. +a.js(19,5): error TS4112: This member cannot have an 'override' modifier because its containing class 'C' does not extend another class. -==== a.js (2 errors) ==== +==== a.js (4 errors) ==== class B { foo (v) {} fooo (v) {} @@ -14,16 +16,20 @@ a.js(9,5): error TS4114: This member must have an 'override' modifier because it !!! error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'. /** @override */ fooo (v) {} - ~~~~ -!!! error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'. /** @override */ bar(v) {} + ~~~ +!!! error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'B'. } class C { foo () {} /** @override */ fooo (v) {} + ~~~~ +!!! error TS4112: This member cannot have an 'override' modifier because its containing class 'C' does not extend another class. /** @override */ bar(v) {} + ~~~ +!!! error TS4112: This member cannot have an 'override' modifier because its containing class 'C' does not extend another class. } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/override_js2.errors.txt b/testdata/baselines/reference/submodule/conformance/override_js2.errors.txt index 79b3b91719..65618f3449 100644 --- a/testdata/baselines/reference/submodule/conformance/override_js2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/override_js2.errors.txt @@ -1,8 +1,10 @@ a.js(7,5): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'. -a.js(9,5): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'. +a.js(11,5): error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'B'. +a.js(17,5): error TS4112: This member cannot have an 'override' modifier because its containing class 'C' does not extend another class. +a.js(19,5): error TS4112: This member cannot have an 'override' modifier because its containing class 'C' does not extend another class. -==== a.js (2 errors) ==== +==== a.js (4 errors) ==== class B { foo (v) {} fooo (v) {} @@ -14,16 +16,20 @@ a.js(9,5): error TS4114: This member must have an 'override' modifier because it !!! error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'. /** @override */ fooo (v) {} - ~~~~ -!!! error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'. /** @override */ bar(v) {} + ~~~ +!!! error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'B'. } class C { foo () {} /** @override */ fooo (v) {} + ~~~~ +!!! error TS4112: This member cannot have an 'override' modifier because its containing class 'C' does not extend another class. /** @override */ bar(v) {} + ~~~ +!!! error TS4112: This member cannot have an 'override' modifier because its containing class 'C' does not extend another class. } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/override_js3.errors.txt b/testdata/baselines/reference/submodule/conformance/override_js3.errors.txt deleted file mode 100644 index db710adc3f..0000000000 --- a/testdata/baselines/reference/submodule/conformance/override_js3.errors.txt +++ /dev/null @@ -1,17 +0,0 @@ -a.js(9,5): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'. - - -==== a.js (1 errors) ==== - class B { - foo (v) {} - fooo (v) {} - } - - class D extends B { - override foo (v) {} - /** @override */ - fooo (v) {} - ~~~~ -!!! error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'. - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/override_js4.errors.txt b/testdata/baselines/reference/submodule/conformance/override_js4.errors.txt new file mode 100644 index 0000000000..9af536777e --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/override_js4.errors.txt @@ -0,0 +1,15 @@ +a.js(7,5): error TS4117: This member cannot have an 'override' modifier because it is not declared in the base class 'A'. Did you mean 'doSomething'? + + +==== a.js (1 errors) ==== + class A { + doSomething() {} + } + + class B extends A { + /** @override */ + doSomethang() {} + ~~~~~~~~~~~ +!!! error TS4117: This member cannot have an 'override' modifier because it is not declared in the base class 'A'. Did you mean 'doSomething'? + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/privateNamesIncompatibleModifiersJs.errors.txt b/testdata/baselines/reference/submodule/conformance/privateNamesIncompatibleModifiersJs.errors.txt new file mode 100644 index 0000000000..267ad3982c --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/privateNamesIncompatibleModifiersJs.errors.txt @@ -0,0 +1,110 @@ +privateNamesIncompatibleModifiersJs.js(3,8): error TS18010: An accessibility modifier cannot be used with a private identifier. +privateNamesIncompatibleModifiersJs.js(8,8): error TS18010: An accessibility modifier cannot be used with a private identifier. +privateNamesIncompatibleModifiersJs.js(13,8): error TS18010: An accessibility modifier cannot be used with a private identifier. +privateNamesIncompatibleModifiersJs.js(18,8): error TS18010: An accessibility modifier cannot be used with a private identifier. +privateNamesIncompatibleModifiersJs.js(23,8): error TS18010: An accessibility modifier cannot be used with a private identifier. +privateNamesIncompatibleModifiersJs.js(28,8): error TS18010: An accessibility modifier cannot be used with a private identifier. +privateNamesIncompatibleModifiersJs.js(33,8): error TS18010: An accessibility modifier cannot be used with a private identifier. +privateNamesIncompatibleModifiersJs.js(37,8): error TS18010: An accessibility modifier cannot be used with a private identifier. +privateNamesIncompatibleModifiersJs.js(42,8): error TS18010: An accessibility modifier cannot be used with a private identifier. +privateNamesIncompatibleModifiersJs.js(46,8): error TS18010: An accessibility modifier cannot be used with a private identifier. +privateNamesIncompatibleModifiersJs.js(51,7): error TS18010: An accessibility modifier cannot be used with a private identifier. +privateNamesIncompatibleModifiersJs.js(55,8): error TS18010: An accessibility modifier cannot be used with a private identifier. + + +==== privateNamesIncompatibleModifiersJs.js (12 errors) ==== + class A { + /** + * @public + ~~~~~~~ + */ + ~~~~~ +!!! error TS18010: An accessibility modifier cannot be used with a private identifier. + #a = 1; + + /** + * @private + ~~~~~~~~ + */ + ~~~~~ +!!! error TS18010: An accessibility modifier cannot be used with a private identifier. + #b = 1; + + /** + * @protected + ~~~~~~~~~~ + */ + ~~~~~ +!!! error TS18010: An accessibility modifier cannot be used with a private identifier. + #c = 1; + + /** + * @public + ~~~~~~~ + */ + ~~~~~ +!!! error TS18010: An accessibility modifier cannot be used with a private identifier. + #aMethod() { return 1; } + + /** + * @private + ~~~~~~~~ + */ + ~~~~~ +!!! error TS18010: An accessibility modifier cannot be used with a private identifier. + #bMethod() { return 1; } + + /** + * @protected + ~~~~~~~~~~ + */ + ~~~~~ +!!! error TS18010: An accessibility modifier cannot be used with a private identifier. + #cMethod() { return 1; } + + /** + * @public + ~~~~~~~ + */ + ~~~~~ +!!! error TS18010: An accessibility modifier cannot be used with a private identifier. + get #aProp() { return 1; } + /** + * @public + ~~~~~~~ + */ + ~~~~~ +!!! error TS18010: An accessibility modifier cannot be used with a private identifier. + set #aProp(value) { } + + /** + * @private + ~~~~~~~~ + */ + ~~~~~ +!!! error TS18010: An accessibility modifier cannot be used with a private identifier. + get #bProp() { return 1; } + /** + * @private + ~~~~~~~~ + */ + ~~~~~ +!!! error TS18010: An accessibility modifier cannot be used with a private identifier. + set #bProp(value) { } + + /** + * @protected + ~~~~~~~~~~ + */ + ~~~~ +!!! error TS18010: An accessibility modifier cannot be used with a private identifier. + get #cProp() { return 1; } + /** + * @protected + ~~~~~~~~~~ + */ + ~~~~~ +!!! error TS18010: An accessibility modifier cannot be used with a private identifier. + set #cProp(value) { } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJs.errors.txt b/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJs.errors.txt deleted file mode 100644 index 2c2ac38279..0000000000 --- a/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJs.errors.txt +++ /dev/null @@ -1,37 +0,0 @@ -uniqueSymbolsDeclarationsInJs.js(11,12): error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. -uniqueSymbolsDeclarationsInJs.js(16,12): error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. - - -==== uniqueSymbolsDeclarationsInJs.js (2 errors) ==== - // classes - class C { - /** - * @readonly - */ - static readonlyStaticCall = Symbol(); - /** - * @type {unique symbol} - * @readonly - */ - static readonlyStaticType; - ~~~~~~~~~~~~~~~~~~ -!!! error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. - /** - * @type {unique symbol} - * @readonly - */ - static readonlyStaticTypeAndCall = Symbol(); - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. - static readwriteStaticCall = Symbol(); - - /** - * @readonly - */ - readonlyCall = Symbol(); - readwriteCall = Symbol(); - } - - /** @type {unique symbol} */ - const a = Symbol(); - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJs.types b/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJs.types index 4b44b1dc5e..e812b448aa 100644 --- a/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJs.types +++ b/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJs.types @@ -9,8 +9,8 @@ class C { * @readonly */ static readonlyStaticCall = Symbol(); ->readonlyStaticCall : symbol ->Symbol() : symbol +>readonlyStaticCall : unique symbol +>Symbol() : unique symbol >Symbol : SymbolConstructor /** @@ -18,15 +18,15 @@ class C { * @readonly */ static readonlyStaticType; ->readonlyStaticType : symbol +>readonlyStaticType : unique symbol /** * @type {unique symbol} * @readonly */ static readonlyStaticTypeAndCall = Symbol(); ->readonlyStaticTypeAndCall : symbol ->Symbol() : symbol +>readonlyStaticTypeAndCall : unique symbol +>Symbol() : unique symbol >Symbol : SymbolConstructor static readwriteStaticCall = Symbol(); diff --git a/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt b/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt index e7c5d274aa..681f7c5f3e 100644 --- a/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt @@ -1,9 +1,8 @@ uniqueSymbolsDeclarationsInJsErrors.js(5,12): error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. -uniqueSymbolsDeclarationsInJsErrors.js(10,12): error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. uniqueSymbolsDeclarationsInJsErrors.js(14,12): error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. -==== uniqueSymbolsDeclarationsInJsErrors.js (3 errors) ==== +==== uniqueSymbolsDeclarationsInJsErrors.js (2 errors) ==== class C { /** * @type {unique symbol} @@ -16,8 +15,6 @@ uniqueSymbolsDeclarationsInJsErrors.js(14,12): error TS1331: A property of a cla * @readonly */ static readonlyType; - ~~~~~~~~~~~~ -!!! error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. /** * @type {unique symbol} */ diff --git a/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJsErrors.types b/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJsErrors.types index f5a9ef8de0..8efd009a30 100644 --- a/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJsErrors.types +++ b/testdata/baselines/reference/submodule/conformance/uniqueSymbolsDeclarationsInJsErrors.types @@ -15,7 +15,7 @@ class C { * @readonly */ static readonlyType; ->readonlyType : symbol +>readonlyType : unique symbol /** * @type {unique symbol} diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAccessibilityTags.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAccessibilityTags.errors.txt.diff index c326831c37..89e2e165b2 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAccessibilityTags.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocAccessibilityTags.errors.txt.diff @@ -1,12 +1,12 @@ --- old.jsdocAccessibilityTags.errors.txt +++ new.jsdocAccessibilityTags.errors.txt @@= skipped -0, +0 lines =@@ --jsdocAccessibilityTag.js(50,14): error TS2341: Property 'priv' is private and only accessible within class 'A'. + jsdocAccessibilityTag.js(50,14): error TS2341: Property 'priv' is private and only accessible within class 'A'. -jsdocAccessibilityTag.js(55,14): error TS2341: Property 'priv2' is private and only accessible within class 'C'. --jsdocAccessibilityTag.js(58,9): error TS2341: Property 'priv' is private and only accessible within class 'A'. --jsdocAccessibilityTag.js(58,24): error TS2445: Property 'prot' is protected and only accessible within class 'A' and its subclasses. --jsdocAccessibilityTag.js(59,9): error TS2341: Property 'priv' is private and only accessible within class 'A'. --jsdocAccessibilityTag.js(59,24): error TS2445: Property 'prot' is protected and only accessible within class 'A' and its subclasses. + jsdocAccessibilityTag.js(58,9): error TS2341: Property 'priv' is private and only accessible within class 'A'. + jsdocAccessibilityTag.js(58,24): error TS2445: Property 'prot' is protected and only accessible within class 'A' and its subclasses. + jsdocAccessibilityTag.js(59,9): error TS2341: Property 'priv' is private and only accessible within class 'A'. + jsdocAccessibilityTag.js(59,24): error TS2445: Property 'prot' is protected and only accessible within class 'A' and its subclasses. -jsdocAccessibilityTag.js(60,9): error TS2341: Property 'priv2' is private and only accessible within class 'C'. -jsdocAccessibilityTag.js(60,25): error TS2445: Property 'prot2' is protected and only accessible within class 'C' and its subclasses. -jsdocAccessibilityTag.js(61,9): error TS2341: Property 'priv2' is private and only accessible within class 'C'. @@ -14,86 +14,32 @@ - - -==== jsdocAccessibilityTag.js (10 errors) ==== -- class A { -- /** -- * Ap docs -- * -- * @private -- */ -- priv = 4; -- /** -- * Aq docs -- * -- * @protected -- */ -- prot = 5; -- /** -- * Ar docs -- * -- * @public -- */ -- pub = 6; -- /** @public */ -- get ack() { return this.priv } -- /** @private */ -- set ack(value) { } -- } -- class C { -- constructor() { -- /** -- * Cp docs -- * -- * @private -- */ -- this.priv2 = 1; -- /** -- * Cq docs -- * -- * @protected -- */ -- this.prot2 = 2; -- /** -- * Cr docs -- * -- * @public -- */ -- this.pub2 = 3; -- } -- h() { return this.priv2 } -- } -- class B extends A { -- m() { -- this.priv + this.prot + this.pub -- ~~~~ --!!! error TS2341: Property 'priv' is private and only accessible within class 'A'. -- } -- } -- class D extends C { -- n() { -- this.priv2 + this.prot2 + this.pub2 ++ ++ ++==== jsdocAccessibilityTag.js (5 errors) ==== + class A { + /** + * Ap docs +@@= skipped -67, +62 lines =@@ + class D extends C { + n() { + this.priv2 + this.prot2 + this.pub2 - ~~~~~ -!!! error TS2341: Property 'priv2' is private and only accessible within class 'C'. -- } -- } -- new A().priv + new A().prot + new A().pub -- ~~~~ --!!! error TS2341: Property 'priv' is private and only accessible within class 'A'. -- ~~~~ --!!! error TS2445: Property 'prot' is protected and only accessible within class 'A' and its subclasses. -- new B().priv + new B().prot + new B().pub -- ~~~~ --!!! error TS2341: Property 'priv' is private and only accessible within class 'A'. -- ~~~~ --!!! error TS2445: Property 'prot' is protected and only accessible within class 'A' and its subclasses. -- new C().priv2 + new C().prot2 + new C().pub2 + } + } + new A().priv + new A().prot + new A().pub +@@= skipped -15, +13 lines =@@ + ~~~~ + !!! error TS2445: Property 'prot' is protected and only accessible within class 'A' and its subclasses. + new C().priv2 + new C().prot2 + new C().pub2 - ~~~~~ -!!! error TS2341: Property 'priv2' is private and only accessible within class 'C'. - ~~~~~ -!!! error TS2445: Property 'prot2' is protected and only accessible within class 'C' and its subclasses. -- new D().priv2 + new D().prot2 + new D().pub2 + new D().priv2 + new D().prot2 + new D().pub2 - ~~~~~ -!!! error TS2341: Property 'priv2' is private and only accessible within class 'C'. - ~~~~~ -!!! error TS2445: Property 'prot2' is protected and only accessible within class 'C' and its subclasses. -- -+ \ No newline at end of file + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOverrideTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOverrideTag1.errors.txt.diff index 0b1f8da542..c90d422fd0 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOverrideTag1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocOverrideTag1.errors.txt.diff @@ -4,25 +4,13 @@ -0.js(27,5): error TS4119: This member must have a JSDoc comment with an '@override' tag because it overrides a member in the base class 'A'. -0.js(32,5): error TS4122: This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class 'A'. -0.js(40,5): error TS4121: This member cannot have a JSDoc comment with an '@override' tag because its containing class 'C' does not extend another class. -- -- --==== 0.js (3 errors) ==== -+0.js(23,5): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'A'. +0.js(27,5): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'A'. -+ -+ -+==== 0.js (2 errors) ==== - class A { - - /** -@@= skipped -26, +25 lines =@@ - * @returns {boolean} - */ - foo (a) { -+ ~~~ -+!!! error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'A'. - return super.foo(a) - } ++0.js(32,5): error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'A'. ++0.js(40,5): error TS4112: This member cannot have an 'override' modifier because its containing class 'C' does not extend another class. + + + ==== 0.js (3 errors) ==== +@@= skipped -31, +31 lines =@@ bar () { ~~~ @@ -33,17 +21,18 @@ /** @override */ baz () { -- ~~~ + ~~~ -!!! error TS4122: This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class 'A'. ++!!! error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'A'. } } -@@= skipped -21, +21 lines =@@ - class C { +@@= skipped -17, +17 lines =@@ /** @override */ foo () { -- ~~~ + ~~~ -!!! error TS4121: This member cannot have a JSDoc comment with an '@override' tag because its containing class 'C' does not extend another class. ++!!! error TS4112: This member cannot have an 'override' modifier because its containing class 'C' does not extend another class. } } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonly.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonly.errors.txt.diff deleted file mode 100644 index 127a80af13..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonly.errors.txt.diff +++ /dev/null @@ -1,34 +0,0 @@ ---- old.jsdocReadonly.errors.txt -+++ new.jsdocReadonly.errors.txt -@@= skipped -0, +0 lines =@@ --jsdocReadonly.js(23,3): error TS2540: Cannot assign to 'y' because it is a read-only property. -- -- --==== jsdocReadonly.js (1 errors) ==== -- class LOL { -- /** -- * @readonly -- * @private -- * @type {number} -- * Order rules do not apply to JSDoc -- */ -- x = 1 -- /** @readonly */ -- y = 2 -- /** @readonly Definitely not here */ -- static z = 3 -- /** @readonly This is OK too */ -- constructor() { -- /** ok */ -- this.y = 2 -- /** @readonly ok */ -- this.ka = 2 -- } -- } -- -- var l = new LOL() -- l.y = 12 -- ~ --!!! error TS2540: Cannot assign to 'y' because it is a read-only property. -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonly.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonly.types.diff index 064200c173..a12f1b5ea8 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonly.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonly.types.diff @@ -1,31 +1,6 @@ --- old.jsdocReadonly.types +++ new.jsdocReadonly.types -@@= skipped -15, +15 lines =@@ - - /** @readonly */ - y = 2 -->y : 2 -+>y : number - >2 : 2 - - /** @readonly Definitely not here */ - static z = 3 -->z : 3 -+>z : number - >3 : 3 - - /** @readonly This is OK too */ -@@= skipped -13, +13 lines =@@ - /** ok */ - this.y = 2 - >this.y = 2 : 2 -->this.y : 2 -+>this.y : number - >this : this -->y : 2 -+>y : number - >2 : 2 - +@@= skipped -36, +36 lines =@@ /** @readonly ok */ this.ka = 2 >this.ka = 2 : 2 @@ -36,14 +11,4 @@ +>ka : number >2 : 2 } - } -@@= skipped -22, +22 lines =@@ - - l.y = 12 - >l.y = 12 : 12 -->l.y : any -+>l.y : number - >l : LOL -->y : any -+>y : number - >12 : 12 + } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonlyDeclarations.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonlyDeclarations.types.diff index 2d7ff5aeb8..a1a57035c7 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonlyDeclarations.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocReadonlyDeclarations.types.diff @@ -1,27 +1,6 @@ --- old.jsdocReadonlyDeclarations.types +++ new.jsdocReadonlyDeclarations.types -@@= skipped -5, +5 lines =@@ - - /** @readonly */ - x = 6 -->x : 6 -+>x : number - >6 : 6 - - /** @readonly */ -@@= skipped -9, +9 lines =@@ - - this.x = n - >this.x = n : any -->this.x : 6 -+>this.x : number - >this : this -->x : 6 -+>x : number - >n : any - - /** -@@= skipped -10, +10 lines =@@ +@@= skipped -24, +24 lines =@@ * @type {number} */ this.y = n @@ -34,13 +13,8 @@ >n : any } } - new C().x -->new C().x : 6 -+>new C().x : number - >new C() : C - >C : typeof C -->x : 6 -+>x : number +@@= skipped -14, +15 lines =@@ + >x : 6 function F() { ->F : typeof F diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/override_js1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/override_js1.errors.txt.diff index 6d37472310..ccd236e619 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/override_js1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/override_js1.errors.txt.diff @@ -3,10 +3,12 @@ @@= skipped -0, +0 lines =@@ - +a.js(7,5): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'. -+a.js(9,5): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'. ++a.js(11,5): error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'B'. ++a.js(17,5): error TS4112: This member cannot have an 'override' modifier because its containing class 'C' does not extend another class. ++a.js(19,5): error TS4112: This member cannot have an 'override' modifier because its containing class 'C' does not extend another class. + + -+==== a.js (2 errors) ==== ++==== a.js (4 errors) ==== + class B { + foo (v) {} + fooo (v) {} @@ -18,16 +20,20 @@ +!!! error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'. + /** @override */ + fooo (v) {} -+ ~~~~ -+!!! error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'. + /** @override */ + bar(v) {} ++ ~~~ ++!!! error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'B'. + } + + class C { + foo () {} + /** @override */ + fooo (v) {} ++ ~~~~ ++!!! error TS4112: This member cannot have an 'override' modifier because its containing class 'C' does not extend another class. + /** @override */ + bar(v) {} ++ ~~~ ++!!! error TS4112: This member cannot have an 'override' modifier because its containing class 'C' does not extend another class. + } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/override_js2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/override_js2.errors.txt.diff index 8a0eb8e549..c635bdd742 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/override_js2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/override_js2.errors.txt.diff @@ -5,18 +5,14 @@ -a.js(11,5): error TS4122: This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class 'B'. -a.js(17,5): error TS4121: This member cannot have a JSDoc comment with an '@override' tag because its containing class 'C' does not extend another class. -a.js(19,5): error TS4121: This member cannot have a JSDoc comment with an '@override' tag because its containing class 'C' does not extend another class. -- -- --==== a.js (4 errors) ==== +a.js(7,5): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'. -+a.js(9,5): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'. -+ -+ -+==== a.js (2 errors) ==== - class B { - foo (v) {} - fooo (v) {} -@@= skipped -12, +10 lines =@@ ++a.js(11,5): error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'B'. ++a.js(17,5): error TS4112: This member cannot have an 'override' modifier because its containing class 'C' does not extend another class. ++a.js(19,5): error TS4112: This member cannot have an 'override' modifier because its containing class 'C' does not extend another class. + + + ==== a.js (4 errors) ==== +@@= skipped -12, +12 lines =@@ class D extends B { foo (v) {} ~~~ @@ -24,22 +20,23 @@ +!!! error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'. /** @override */ fooo (v) {} -+ ~~~~ -+!!! error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'. /** @override */ bar(v) {} -- ~~~ + ~~~ -!!! error TS4122: This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class 'B'. ++!!! error TS4113: This member cannot have an 'override' modifier because it is not declared in the base class 'B'. } class C { - foo () {} +@@= skipped -14, +14 lines =@@ /** @override */ fooo (v) {} -- ~~~~ + ~~~~ -!!! error TS4121: This member cannot have a JSDoc comment with an '@override' tag because its containing class 'C' does not extend another class. ++!!! error TS4112: This member cannot have an 'override' modifier because its containing class 'C' does not extend another class. /** @override */ bar(v) {} -- ~~~ + ~~~ -!!! error TS4121: This member cannot have a JSDoc comment with an '@override' tag because its containing class 'C' does not extend another class. ++!!! error TS4112: This member cannot have an 'override' modifier because its containing class 'C' does not extend another class. } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/override_js3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/override_js3.errors.txt.diff index dcf4c96831..81561936e0 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/override_js3.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/override_js3.errors.txt.diff @@ -2,19 +2,20 @@ +++ new.override_js3.errors.txt @@= skipped -0, +0 lines =@@ -a.js(7,5): error TS8009: The 'override' modifier can only be used in TypeScript files. -+a.js(9,5): error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'. - - - ==== a.js (1 errors) ==== -@@= skipped -8, +8 lines =@@ - - class D extends B { - override foo (v) {} +- +- +-==== a.js (1 errors) ==== +- class B { +- foo (v) {} +- fooo (v) {} +- } +- +- class D extends B { +- override foo (v) {} - ~~~~~~~~ -!!! error TS8009: The 'override' modifier can only be used in TypeScript files. - /** @override */ - fooo (v) {} -+ ~~~~ -+!!! error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'B'. - } - \ No newline at end of file +- /** @override */ +- fooo (v) {} +- } +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/override_js4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/override_js4.errors.txt.diff index 91d79a9e86..84e50604f8 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/override_js4.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/override_js4.errors.txt.diff @@ -2,18 +2,15 @@ +++ new.override_js4.errors.txt @@= skipped -0, +0 lines =@@ -a.js(7,5): error TS4123: This member cannot have a JSDoc comment with an 'override' tag because it is not declared in the base class 'A'. Did you mean 'doSomething'? -- -- --==== a.js (1 errors) ==== -- class A { -- doSomething() {} -- } -- -- class B extends A { -- /** @override */ -- doSomethang() {} -- ~~~~~~~~~~~ ++a.js(7,5): error TS4117: This member cannot have an 'override' modifier because it is not declared in the base class 'A'. Did you mean 'doSomething'? + + + ==== a.js (1 errors) ==== +@@= skipped -9, +9 lines =@@ + /** @override */ + doSomethang() {} + ~~~~~~~~~~~ -!!! error TS4123: This member cannot have a JSDoc comment with an 'override' tag because it is not declared in the base class 'A'. Did you mean 'doSomething'? -- } -- -+ \ No newline at end of file ++!!! error TS4117: This member cannot have an 'override' modifier because it is not declared in the base class 'A'. Did you mean 'doSomething'? + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/privateNamesIncompatibleModifiersJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/privateNamesIncompatibleModifiersJs.errors.txt.diff deleted file mode 100644 index fd0636e013..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/privateNamesIncompatibleModifiersJs.errors.txt.diff +++ /dev/null @@ -1,114 +0,0 @@ ---- old.privateNamesIncompatibleModifiersJs.errors.txt -+++ new.privateNamesIncompatibleModifiersJs.errors.txt -@@= skipped -0, +0 lines =@@ --privateNamesIncompatibleModifiersJs.js(3,8): error TS18010: An accessibility modifier cannot be used with a private identifier. --privateNamesIncompatibleModifiersJs.js(8,8): error TS18010: An accessibility modifier cannot be used with a private identifier. --privateNamesIncompatibleModifiersJs.js(13,8): error TS18010: An accessibility modifier cannot be used with a private identifier. --privateNamesIncompatibleModifiersJs.js(18,8): error TS18010: An accessibility modifier cannot be used with a private identifier. --privateNamesIncompatibleModifiersJs.js(23,8): error TS18010: An accessibility modifier cannot be used with a private identifier. --privateNamesIncompatibleModifiersJs.js(28,8): error TS18010: An accessibility modifier cannot be used with a private identifier. --privateNamesIncompatibleModifiersJs.js(33,8): error TS18010: An accessibility modifier cannot be used with a private identifier. --privateNamesIncompatibleModifiersJs.js(37,8): error TS18010: An accessibility modifier cannot be used with a private identifier. --privateNamesIncompatibleModifiersJs.js(42,8): error TS18010: An accessibility modifier cannot be used with a private identifier. --privateNamesIncompatibleModifiersJs.js(46,8): error TS18010: An accessibility modifier cannot be used with a private identifier. --privateNamesIncompatibleModifiersJs.js(51,7): error TS18010: An accessibility modifier cannot be used with a private identifier. --privateNamesIncompatibleModifiersJs.js(55,8): error TS18010: An accessibility modifier cannot be used with a private identifier. -- -- --==== privateNamesIncompatibleModifiersJs.js (12 errors) ==== -- class A { -- /** -- * @public -- ~~~~~~~ -- */ -- ~~~~~ --!!! error TS18010: An accessibility modifier cannot be used with a private identifier. -- #a = 1; -- -- /** -- * @private -- ~~~~~~~~ -- */ -- ~~~~~ --!!! error TS18010: An accessibility modifier cannot be used with a private identifier. -- #b = 1; -- -- /** -- * @protected -- ~~~~~~~~~~ -- */ -- ~~~~~ --!!! error TS18010: An accessibility modifier cannot be used with a private identifier. -- #c = 1; -- -- /** -- * @public -- ~~~~~~~ -- */ -- ~~~~~ --!!! error TS18010: An accessibility modifier cannot be used with a private identifier. -- #aMethod() { return 1; } -- -- /** -- * @private -- ~~~~~~~~ -- */ -- ~~~~~ --!!! error TS18010: An accessibility modifier cannot be used with a private identifier. -- #bMethod() { return 1; } -- -- /** -- * @protected -- ~~~~~~~~~~ -- */ -- ~~~~~ --!!! error TS18010: An accessibility modifier cannot be used with a private identifier. -- #cMethod() { return 1; } -- -- /** -- * @public -- ~~~~~~~ -- */ -- ~~~~~ --!!! error TS18010: An accessibility modifier cannot be used with a private identifier. -- get #aProp() { return 1; } -- /** -- * @public -- ~~~~~~~ -- */ -- ~~~~~ --!!! error TS18010: An accessibility modifier cannot be used with a private identifier. -- set #aProp(value) { } -- -- /** -- * @private -- ~~~~~~~~ -- */ -- ~~~~~ --!!! error TS18010: An accessibility modifier cannot be used with a private identifier. -- get #bProp() { return 1; } -- /** -- * @private -- ~~~~~~~~ -- */ -- ~~~~~ --!!! error TS18010: An accessibility modifier cannot be used with a private identifier. -- set #bProp(value) { } -- -- /** -- * @protected -- ~~~~~~~~~~ -- */ -- ~~~~ --!!! error TS18010: An accessibility modifier cannot be used with a private identifier. -- get #cProp() { return 1; } -- /** -- * @protected -- ~~~~~~~~~~ -- */ -- ~~~~~ --!!! error TS18010: An accessibility modifier cannot be used with a private identifier. -- set #cProp(value) { } -- } -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJs.errors.txt.diff deleted file mode 100644 index d8f7e8eb4c..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJs.errors.txt.diff +++ /dev/null @@ -1,41 +0,0 @@ ---- old.uniqueSymbolsDeclarationsInJs.errors.txt -+++ new.uniqueSymbolsDeclarationsInJs.errors.txt -@@= skipped -0, +0 lines =@@ -- -+uniqueSymbolsDeclarationsInJs.js(11,12): error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. -+uniqueSymbolsDeclarationsInJs.js(16,12): error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. -+ -+ -+==== uniqueSymbolsDeclarationsInJs.js (2 errors) ==== -+ // classes -+ class C { -+ /** -+ * @readonly -+ */ -+ static readonlyStaticCall = Symbol(); -+ /** -+ * @type {unique symbol} -+ * @readonly -+ */ -+ static readonlyStaticType; -+ ~~~~~~~~~~~~~~~~~~ -+!!! error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. -+ /** -+ * @type {unique symbol} -+ * @readonly -+ */ -+ static readonlyStaticTypeAndCall = Symbol(); -+ ~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. -+ static readwriteStaticCall = Symbol(); -+ -+ /** -+ * @readonly -+ */ -+ readonlyCall = Symbol(); -+ readwriteCall = Symbol(); -+ } -+ -+ /** @type {unique symbol} */ -+ const a = Symbol(); -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJs.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJs.types.diff deleted file mode 100644 index 945ead90c6..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJs.types.diff +++ /dev/null @@ -1,32 +0,0 @@ ---- old.uniqueSymbolsDeclarationsInJs.types -+++ new.uniqueSymbolsDeclarationsInJs.types -@@= skipped -8, +8 lines =@@ - * @readonly - */ - static readonlyStaticCall = Symbol(); -->readonlyStaticCall : unique symbol -->Symbol() : unique symbol -+>readonlyStaticCall : symbol -+>Symbol() : symbol - >Symbol : SymbolConstructor - - /** -@@= skipped -9, +9 lines =@@ - * @readonly - */ - static readonlyStaticType; -->readonlyStaticType : unique symbol -+>readonlyStaticType : symbol - - /** - * @type {unique symbol} - * @readonly - */ - static readonlyStaticTypeAndCall = Symbol(); -->readonlyStaticTypeAndCall : unique symbol -->Symbol() : unique symbol -+>readonlyStaticTypeAndCall : symbol -+>Symbol() : symbol - >Symbol : SymbolConstructor - - static readwriteStaticCall = Symbol(); \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt.diff deleted file mode 100644 index bb59446973..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJsErrors.errors.txt.diff +++ /dev/null @@ -1,22 +0,0 @@ ---- old.uniqueSymbolsDeclarationsInJsErrors.errors.txt -+++ new.uniqueSymbolsDeclarationsInJsErrors.errors.txt -@@= skipped -0, +0 lines =@@ - uniqueSymbolsDeclarationsInJsErrors.js(5,12): error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. -+uniqueSymbolsDeclarationsInJsErrors.js(10,12): error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. - uniqueSymbolsDeclarationsInJsErrors.js(14,12): error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. - - --==== uniqueSymbolsDeclarationsInJsErrors.js (2 errors) ==== -+==== uniqueSymbolsDeclarationsInJsErrors.js (3 errors) ==== - class C { - /** - * @type {unique symbol} -@@= skipped -14, +15 lines =@@ - * @readonly - */ - static readonlyType; -+ ~~~~~~~~~~~~ -+!!! error TS1331: A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'. - /** - * @type {unique symbol} - */ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJsErrors.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJsErrors.types.diff deleted file mode 100644 index cda47b348c..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/uniqueSymbolsDeclarationsInJsErrors.types.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.uniqueSymbolsDeclarationsInJsErrors.types -+++ new.uniqueSymbolsDeclarationsInJsErrors.types -@@= skipped -14, +14 lines =@@ - * @readonly - */ - static readonlyType; -->readonlyType : unique symbol -+>readonlyType : symbol - - /** - * @type {unique symbol} \ No newline at end of file