Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report grammar errors for invalid decorator grammar #57749

Merged
merged 3 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Additional tests
  • Loading branch information
rbuckton committed Mar 13, 2024
commit 3526677597e5a1734e0688649fce5d8ce02683a4
53 changes: 27 additions & 26 deletions src/testRunner/compilerRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,42 +128,43 @@ export class CompilerBaselineRunner extends RunnerBase {

class CompilerTest {
private static varyBy: readonly string[] = [
"module",
"moduleResolution",
"moduleDetection",
"allowArbitraryExtensions",
"allowImportingTsExtensions",
"target",
"jsx",
"noEmit",
"removeComments",
"allowSyntheticDefaultImports",
"alwaysStrict",
"downlevelIteration",
"experimentalDecorators",
"emitDecoratorMetadata",
"esModuleInterop",
"exactOptionalPropertyTypes",
"importHelpers",
"importHelpers",
"downlevelIteration",
"isolatedModules",
"verbatimModuleSyntax",
"strict",
"jsx",
"module",
"moduleDetection",
"moduleResolution",
"noEmit",
"noImplicitAny",
"strictNullChecks",
"strictFunctionTypes",
"strictBindCallApply",
"strictPropertyInitialization",
"noImplicitThis",
"alwaysStrict",
"allowSyntheticDefaultImports",
"esModuleInterop",
"emitDecoratorMetadata",
"skipDefaultLibCheck",
"noPropertyAccessFromIndexSignature",
"noUncheckedIndexedAccess",
"preserveConstEnums",
"removeComments",
"resolveJsonModule",
"resolvePackageJsonExports",
"resolvePackageJsonImports",
"skipDefaultLibCheck",
"skipLibCheck",
"exactOptionalPropertyTypes",
"strict",
"strictBindCallApply",
"strictFunctionTypes",
"strictNullChecks",
"strictPropertyInitialization",
"target",
"useDefineForClassFields",
"useUnknownInCatchVariables",
"noUncheckedIndexedAccess",
"noPropertyAccessFromIndexSignature",
"resolvePackageJsonExports",
"resolvePackageJsonImports",
"resolveJsonModule",
"allowArbitraryExtensions",
"verbatimModuleSyntax",
];
private fileName: string;
private justName: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
esDecorators-decoratorExpression.1.ts(3,4): error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
esDecorators-decoratorExpression.1.ts(5,4): error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
esDecorators-decoratorExpression.1.ts(7,4): error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
esDecorators-decoratorExpression.1.ts(9,4): error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
esDecorators-decoratorExpression.1.ts(11,4): error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
esDecorators-decoratorExpression.1.ts(13,4): error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
esDecorators-decoratorExpression.1.ts(15,4): error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
esDecorators-decoratorExpression.1.ts(17,4): error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
esDecorators-decoratorExpression.1.ts(19,4): error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
esDecorators-decoratorExpression.1.ts(21,4): error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
esDecorators-decoratorExpression.1.ts(23,4): error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
esDecorators-decoratorExpression.1.ts(25,14): error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
esDecorators-decoratorExpression.1.ts(27,14): error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
esDecorators-decoratorExpression.1.ts(29,14): error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
esDecorators-decoratorExpression.1.ts(31,14): error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
esDecorators-decoratorExpression.1.ts(33,14): error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
esDecorators-decoratorExpression.1.ts(35,14): error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
esDecorators-decoratorExpression.1.ts(37,14): error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
esDecorators-decoratorExpression.1.ts(39,14): error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
esDecorators-decoratorExpression.1.ts(41,14): error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
esDecorators-decoratorExpression.1.ts(43,14): error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
esDecorators-decoratorExpression.1.ts(45,14): error TS1497: Expression must be enclosed in parentheses to be used as a decorator.


==== esDecorators-decoratorExpression.1.ts (22 errors) ====
declare let x: any;

{ @x().y class C {} }
~~~~~
!!! error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
!!! related TS1498 esDecorators-decoratorExpression.1.ts:3:4: Invalid syntax in decorator.

{ @new x class C {} }
~~~~~
!!! error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
!!! related TS1498 esDecorators-decoratorExpression.1.ts:5:4: Invalid syntax in decorator.

{ @x().y() class C {} }
~~~~~~~
!!! error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
!!! related TS1498 esDecorators-decoratorExpression.1.ts:7:4: Invalid syntax in decorator.

{ @x?.y class C {} }
~~~~
!!! error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
!!! related TS1498 esDecorators-decoratorExpression.1.ts:9:5: Invalid syntax in decorator.

{ @x?.y() class C {} }
~~~~~~
!!! error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
!!! related TS1498 esDecorators-decoratorExpression.1.ts:11:5: Invalid syntax in decorator.

{ @x?.["y"] class C {} }
~~~~~~~~
!!! error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
!!! related TS1498 esDecorators-decoratorExpression.1.ts:13:4: Invalid syntax in decorator.

{ @x?.() class C {} }
~~~~~
!!! error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
!!! related TS1498 esDecorators-decoratorExpression.1.ts:15:5: Invalid syntax in decorator.

{ @x`` class C {} }
~~~
!!! error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
!!! related TS1498 esDecorators-decoratorExpression.1.ts:17:4: Invalid syntax in decorator.

{ @x``() class C {} }
~~~~~
!!! error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
!!! related TS1498 esDecorators-decoratorExpression.1.ts:19:4: Invalid syntax in decorator.

{ @x.y`` class C {} }
~~~~~
!!! error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
!!! related TS1498 esDecorators-decoratorExpression.1.ts:21:4: Invalid syntax in decorator.

{ @x.y``() class C {} }
~~~~~~~
!!! error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
!!! related TS1498 esDecorators-decoratorExpression.1.ts:23:4: Invalid syntax in decorator.

{ class C { @x().y m() {} } }
~~~~~
!!! error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
!!! related TS1498 esDecorators-decoratorExpression.1.ts:25:14: Invalid syntax in decorator.

{ class C { @new x m() {} } }
~~~~~
!!! error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
!!! related TS1498 esDecorators-decoratorExpression.1.ts:27:14: Invalid syntax in decorator.

{ class C { @x().y() m() {} } }
~~~~~~~
!!! error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
!!! related TS1498 esDecorators-decoratorExpression.1.ts:29:14: Invalid syntax in decorator.

{ class C { @x?.y m() {} } }
~~~~
!!! error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
!!! related TS1498 esDecorators-decoratorExpression.1.ts:31:15: Invalid syntax in decorator.

{ class C { @x?.y() m() {} } }
~~~~~~
!!! error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
!!! related TS1498 esDecorators-decoratorExpression.1.ts:33:15: Invalid syntax in decorator.

{ class C { @x?.["y"] m() {} } }
~~~~~~~~
!!! error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
!!! related TS1498 esDecorators-decoratorExpression.1.ts:35:14: Invalid syntax in decorator.

{ class C { @x?.() m() {} } }
~~~~~
!!! error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
!!! related TS1498 esDecorators-decoratorExpression.1.ts:37:15: Invalid syntax in decorator.

{ class C { @x`` m() {} } }
~~~
!!! error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
!!! related TS1498 esDecorators-decoratorExpression.1.ts:39:14: Invalid syntax in decorator.

{ class C { @x``() m() {} } }
~~~~~
!!! error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
!!! related TS1498 esDecorators-decoratorExpression.1.ts:41:14: Invalid syntax in decorator.

{ class C { @x.y`` m() {} } }
~~~~~
!!! error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
!!! related TS1498 esDecorators-decoratorExpression.1.ts:43:14: Invalid syntax in decorator.

{ class C { @x.y``() m() {} } }
~~~~~~~
!!! error TS1497: Expression must be enclosed in parentheses to be used as a decorator.
!!! related TS1498 esDecorators-decoratorExpression.1.ts:45:14: Invalid syntax in decorator.

Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
//// [tests/cases/conformance/esDecorators/esDecorators-decoratorExpression.1.ts] ////

//// [esDecorators-decoratorExpression.1.ts]
declare let x: any;

{ @x().y class C {} }

{ @new x class C {} }

{ @x().y() class C {} }

{ @x?.y class C {} }

{ @x?.y() class C {} }

{ @x?.["y"] class C {} }

{ @x?.() class C {} }

{ @x`` class C {} }

{ @x``() class C {} }

{ @x.y`` class C {} }

{ @x.y``() class C {} }

{ class C { @x().y m() {} } }

{ class C { @new x m() {} } }

{ class C { @x().y() m() {} } }

{ class C { @x?.y m() {} } }

{ class C { @x?.y() m() {} } }

{ class C { @x?.["y"] m() {} } }

{ class C { @x?.() m() {} } }

{ class C { @x`` m() {} } }

{ class C { @x``() m() {} } }

{ class C { @x.y`` m() {} } }

{ class C { @x.y``() m() {} } }


//// [esDecorators-decoratorExpression.1.js]
{
@x().y
class C {
}
}
{
@new x
class C {
}
}
{
@x().y()
class C {
}
}
{
@x?.y
class C {
}
}
{
@x?.y()
class C {
}
}
{
@x?.["y"]
class C {
}
}
{
@x?.()
class C {
}
}
{
@x ``
class C {
}
}
{
@x ``()
class C {
}
}
{
@x.y ``
class C {
}
}
{
@x.y ``()
class C {
}
}
{
class C {
@x().y
m() { }
}
}
{
class C {
@new x
m() { }
}
}
{
class C {
@x().y()
m() { }
}
}
{
class C {
@x?.y
m() { }
}
}
{
class C {
@x?.y()
m() { }
}
}
{
class C {
@x?.["y"]
m() { }
}
}
{
class C {
@x?.()
m() { }
}
}
{
class C {
@x ``
m() { }
}
}
{
class C {
@x ``()
m() { }
}
}
{
class C {
@x.y ``
m() { }
}
}
{
class C {
@x.y ``()
m() { }
}
}
Loading
Loading