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 tsc/internal/checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -9373,7 +9373,7 @@ func (c *Checker) getLegacyDecoratorArgumentCount(node *ast.Node, signature *Sig
return 2
case ast.KindMethodDeclaration, ast.KindGetAccessor, ast.KindSetAccessor:
// For decorators with only two parameters we supply only two arguments
if len(signature.parameters) <= 2 {
if c.getParameterCount(signature) <= 2 {
return 2
}
return 3
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
decoratorRestNoCrash1.ts(4,29): error TS2339: Property 'greeting' does not exist on type 'Greeter'.


==== decoratorRestNoCrash1.ts (1 errors) ====
class Greeter {
@deco
greet1() {
return "Hello, " + this.greeting;
~~~~~~~~
!!! error TS2339: Property 'greeting' does not exist on type 'Greeter'.
}
}

declare function deco(...args: [any, any, any]): any;

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//// [tests/cases/compiler/decoratorRestNoCrash1.ts] ////

=== decoratorRestNoCrash1.ts ===
class Greeter {
>Greeter : Symbol(Greeter, Decl(decoratorRestNoCrash1.ts, 0, 0))

@deco
>deco : Symbol(deco, Decl(decoratorRestNoCrash1.ts, 5, 1))

greet1() {
>greet1 : Symbol(Greeter.greet1, Decl(decoratorRestNoCrash1.ts, 0, 15))

return "Hello, " + this.greeting;
>this : Symbol(Greeter, Decl(decoratorRestNoCrash1.ts, 0, 0))
}
}

declare function deco(...args: [any, any, any]): any;
>deco : Symbol(deco, Decl(decoratorRestNoCrash1.ts, 5, 1))
>args : Symbol(args, Decl(decoratorRestNoCrash1.ts, 7, 22))

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//// [tests/cases/compiler/decoratorRestNoCrash1.ts] ////

=== decoratorRestNoCrash1.ts ===
class Greeter {
>Greeter : Greeter

@deco
>deco : (args_0: any, args_1: any, args_2: any) => any

greet1() {
>greet1 : () => string

return "Hello, " + this.greeting;
>"Hello, " + this.greeting : string
>"Hello, " : "Hello, "
>this.greeting : any
>this : this
>greeting : any
}
}

declare function deco(...args: [any, any, any]): any;
>deco : (args_0: any, args_1: any, args_2: any) => any
>args : [any, any, any]

12 changes: 12 additions & 0 deletions tsc/testdata/tests/cases/compiler/decoratorRestNoCrash1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// @strict: true
// @noEmit: true
// @experimentalDecorators: true

class Greeter {
@deco
greet1() {
return "Hello, " + this.greeting;
}
}

declare function deco(...args: [any, any, any]): any;