mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
Support modifiers on object literal methods and accessors, and question tokens on object literal methods.
This makes parsing of these constructs the same whether they are in an object literal or a class. This is important for incrementla parsing for knowing if we can reuse these nodes if we run into them.
This commit is contained in:
@@ -1,17 +1,14 @@
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration5_es6.ts(1,14): error TS1138: Parameter declaration expected.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration5_es6.ts(1,19): error TS1005: ';' expected.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration5_es6.ts(1,10): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration5_es6.ts(1,14): error TS2304: Cannot find name 'yield'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration5_es6.ts (4 errors) ====
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration5_es6.ts (3 errors) ====
|
||||
function*foo(yield) {
|
||||
~~~~~
|
||||
!!! error TS1138: Parameter declaration expected.
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
||||
~~~
|
||||
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
~~~~~
|
||||
!!! error TS2304: Cannot find name 'yield'.
|
||||
}
|
||||
@@ -2,10 +2,11 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWit
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers2.ts(4,14): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers2.ts(11,9): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers2.ts(20,5): error TS2300: Duplicate identifier 'foo'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers2.ts(20,9): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers2.ts(21,5): error TS2300: Duplicate identifier 'foo'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers2.ts (5 errors) ====
|
||||
==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers2.ts (6 errors) ====
|
||||
// Optional parameters allow initializers only in implementation signatures
|
||||
// All the below declarations are errors
|
||||
|
||||
@@ -34,6 +35,8 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWit
|
||||
!!! error TS1005: '{' expected.
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
~~~~~
|
||||
!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
|
||||
foo(x = 1) { }, // error
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier 'foo'.
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
tests/cases/compiler/dottedModuleName.ts(3,29): error TS1144: '{' or ';' expected.
|
||||
tests/cases/compiler/dottedModuleName.ts(3,18): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
tests/cases/compiler/dottedModuleName.ts(3,33): error TS2304: Cannot find name 'x'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/dottedModuleName.ts (3 errors) ====
|
||||
==== tests/cases/compiler/dottedModuleName.ts (2 errors) ====
|
||||
module M {
|
||||
export module N {
|
||||
export function f(x:number)=>2*x;
|
||||
~~
|
||||
!!! error TS1144: '{' or ';' expected.
|
||||
~
|
||||
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'x'.
|
||||
export module X.Y.Z {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
tests/cases/compiler/modifiersOnInterfaceIndexSignature1.ts(2,3): error TS1145: Modifiers not permitted on index signature members.
|
||||
|
||||
|
||||
==== tests/cases/compiler/modifiersOnInterfaceIndexSignature1.ts (1 errors) ====
|
||||
interface I {
|
||||
public [a: string]: number;
|
||||
~~~~~~
|
||||
!!! error TS1145: Modifiers not permitted on index signature members.
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
tests/cases/compiler/objectLiteralMemberWithModifiers1.ts(1,11): error TS1184: Modifiers cannot appear here.
|
||||
|
||||
|
||||
==== tests/cases/compiler/objectLiteralMemberWithModifiers1.ts (1 errors) ====
|
||||
var v = { public foo() { } }
|
||||
~~~~~~
|
||||
!!! error TS1184: Modifiers cannot appear here.
|
||||
@@ -0,0 +1,7 @@
|
||||
tests/cases/compiler/objectLiteralMemberWithModifiers2.ts(1,11): error TS1184: Modifiers cannot appear here.
|
||||
|
||||
|
||||
==== tests/cases/compiler/objectLiteralMemberWithModifiers2.ts (1 errors) ====
|
||||
var v = { public get foo() { } }
|
||||
~~~~~~
|
||||
!!! error TS1184: Modifiers cannot appear here.
|
||||
@@ -0,0 +1,7 @@
|
||||
tests/cases/compiler/objectLiteralMemberWithQuestionMark1.ts(1,14): error TS1112: A class member cannot be declared optional.
|
||||
|
||||
|
||||
==== tests/cases/compiler/objectLiteralMemberWithQuestionMark1.ts (1 errors) ====
|
||||
var v = { foo?() { } }
|
||||
~
|
||||
!!! error TS1112: A class member cannot be declared optional.
|
||||
@@ -0,0 +1,7 @@
|
||||
tests/cases/compiler/objectLiteralMemberWithoutBlock1.ts(1,16): error TS1005: '{' expected.
|
||||
|
||||
|
||||
==== tests/cases/compiler/objectLiteralMemberWithoutBlock1.ts (1 errors) ====
|
||||
var v = { foo(); }
|
||||
~
|
||||
!!! error TS1005: '{' expected.
|
||||
@@ -11,11 +11,9 @@ tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWith
|
||||
tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties2.ts(25,8): error TS1005: '{' expected.
|
||||
tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties2.ts(25,9): error TS1136: Property assignment expected.
|
||||
tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties2.ts(26,1): error TS1005: ':' expected.
|
||||
tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties2.ts(12,5): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties2.ts(20,5): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties2.ts (15 errors) ====
|
||||
==== tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWithOptionalProperties2.ts (13 errors) ====
|
||||
// Illegal attempts to define optional methods
|
||||
|
||||
var a: {
|
||||
@@ -40,8 +38,6 @@ tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWith
|
||||
!!! error TS1144: '{' or ';' expected.
|
||||
~
|
||||
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
|
||||
~
|
||||
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
}
|
||||
|
||||
interface I2<T> {
|
||||
@@ -58,8 +54,6 @@ tests/cases/conformance/types/objectTypeLiteral/methodSignatures/objectTypesWith
|
||||
!!! error TS1144: '{' or ';' expected.
|
||||
~
|
||||
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
|
||||
~
|
||||
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
tests/cases/conformance/parser/ecmascript5/Accessors/parserAccessors10.ts(2,10): error TS1005: ':' expected.
|
||||
tests/cases/conformance/parser/ecmascript5/Accessors/parserAccessors10.ts(2,14): error TS1005: ',' expected.
|
||||
tests/cases/conformance/parser/ecmascript5/Accessors/parserAccessors10.ts(2,10): error TS2304: Cannot find name 'get'.
|
||||
tests/cases/conformance/parser/ecmascript5/Accessors/parserAccessors10.ts(2,3): error TS1184: Modifiers cannot appear here.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/Accessors/parserAccessors10.ts (3 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/Accessors/parserAccessors10.ts (1 errors) ====
|
||||
var v = {
|
||||
public get foo() { }
|
||||
~~~
|
||||
!!! error TS1005: ':' expected.
|
||||
~~~
|
||||
!!! error TS1005: ',' expected.
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'get'.
|
||||
~~~~~~
|
||||
!!! error TS1184: Modifiers cannot appear here.
|
||||
};
|
||||
@@ -1,19 +1,7 @@
|
||||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts(1,18): error TS1005: ':' expected.
|
||||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts(1,28): error TS1005: ',' expected.
|
||||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts(1,32): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts(1,18): error TS2304: Cannot find name 'get'.
|
||||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts(1,23): error TS2304: Cannot find name 'e'.
|
||||
tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts(1,11): error TS1184: Modifiers cannot appear here.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts (5 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName5.ts (1 errors) ====
|
||||
var v = { public get [e]() { } };
|
||||
~~~
|
||||
!!! error TS1005: ':' expected.
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'get'.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'e'.
|
||||
~~~~~~
|
||||
!!! error TS1184: Modifiers cannot appear here.
|
||||
@@ -1,10 +1,7 @@
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserErrantEqualsGreaterThanAfterFunction1.ts(1,14): error TS1144: '{' or ';' expected.
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserErrantEqualsGreaterThanAfterFunction1.ts(1,10): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserErrantEqualsGreaterThanAfterFunction1.ts (2 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserErrantEqualsGreaterThanAfterFunction1.ts (1 errors) ====
|
||||
function f() => 4;
|
||||
~~
|
||||
!!! error TS1144: '{' or ';' expected.
|
||||
~
|
||||
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
!!! error TS1144: '{' or ';' expected.
|
||||
@@ -1,15 +1,12 @@
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserErrantEqualsGreaterThanAfterFunction2.ts(1,18): error TS1144: '{' or ';' expected.
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserErrantEqualsGreaterThanAfterFunction2.ts(1,10): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserErrantEqualsGreaterThanAfterFunction2.ts(1,15): error TS2304: Cannot find name 'A'.
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserErrantEqualsGreaterThanAfterFunction2.ts(1,21): error TS2304: Cannot find name 'p'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserErrantEqualsGreaterThanAfterFunction2.ts (4 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserErrantEqualsGreaterThanAfterFunction2.ts (3 errors) ====
|
||||
function f(p: A) => p;
|
||||
~~
|
||||
!!! error TS1144: '{' or ';' expected.
|
||||
~
|
||||
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'A'.
|
||||
~
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ParameterLists/parserErrorRecovery_ParameterList6.ts(2,23): error TS1110: Type expected.
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ParameterLists/parserErrorRecovery_ParameterList6.ts(2,28): error TS1003: Identifier expected.
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ParameterLists/parserErrorRecovery_ParameterList6.ts(3,1): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ParameterLists/parserErrorRecovery_ParameterList6.ts(2,12): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ParameterLists/parserErrorRecovery_ParameterList6.ts (4 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ParameterLists/parserErrorRecovery_ParameterList6.ts (3 errors) ====
|
||||
class Foo {
|
||||
public banana (x: break) { }
|
||||
~~~~~
|
||||
!!! error TS1110: Type expected.
|
||||
~
|
||||
!!! error TS1003: Identifier expected.
|
||||
~~~~~~
|
||||
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
}
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
@@ -6,10 +6,9 @@ tests/cases/conformance/parser/ecmascript5/SkippedTokens/parserSkippedTokens16.t
|
||||
tests/cases/conformance/parser/ecmascript5/SkippedTokens/parserSkippedTokens16.ts(8,14): error TS1109: Expression expected.
|
||||
tests/cases/conformance/parser/ecmascript5/SkippedTokens/parserSkippedTokens16.ts(1,1): error TS2304: Cannot find name 'foo'.
|
||||
tests/cases/conformance/parser/ecmascript5/SkippedTokens/parserSkippedTokens16.ts(1,8): error TS2304: Cannot find name 'Bar'.
|
||||
tests/cases/conformance/parser/ecmascript5/SkippedTokens/parserSkippedTokens16.ts(2,10): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/SkippedTokens/parserSkippedTokens16.ts (9 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/SkippedTokens/parserSkippedTokens16.ts (8 errors) ====
|
||||
foo(): Bar { }
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
||||
@@ -22,8 +21,6 @@ tests/cases/conformance/parser/ecmascript5/SkippedTokens/parserSkippedTokens16.t
|
||||
function Foo () # { }
|
||||
|
||||
!!! error TS1127: Invalid character.
|
||||
~~~
|
||||
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||
4+:5
|
||||
~
|
||||
!!! error TS1109: Expression expected.
|
||||
|
||||
@@ -1,54 +1,27 @@
|
||||
tests/cases/conformance/classes/indexMemberDeclarations/privateIndexer2.ts(4,13): error TS1005: ':' expected.
|
||||
tests/cases/conformance/classes/indexMemberDeclarations/privateIndexer2.ts(4,15): error TS1005: ',' expected.
|
||||
tests/cases/conformance/classes/indexMemberDeclarations/privateIndexer2.ts(4,24): error TS1005: ',' expected.
|
||||
tests/cases/conformance/classes/indexMemberDeclarations/privateIndexer2.ts(4,15): error TS1005: ']' expected.
|
||||
tests/cases/conformance/classes/indexMemberDeclarations/privateIndexer2.ts(4,23): error TS1005: ',' expected.
|
||||
tests/cases/conformance/classes/indexMemberDeclarations/privateIndexer2.ts(4,24): error TS1136: Property assignment expected.
|
||||
tests/cases/conformance/classes/indexMemberDeclarations/privateIndexer2.ts(4,32): error TS1005: ':' expected.
|
||||
tests/cases/conformance/classes/indexMemberDeclarations/privateIndexer2.ts(5,1): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/classes/indexMemberDeclarations/privateIndexer2.ts(8,5): error TS1131: Property or signature expected.
|
||||
tests/cases/conformance/classes/indexMemberDeclarations/privateIndexer2.ts(8,14): error TS1005: ']' expected.
|
||||
tests/cases/conformance/classes/indexMemberDeclarations/privateIndexer2.ts(8,22): error TS1005: ';' expected.
|
||||
tests/cases/conformance/classes/indexMemberDeclarations/privateIndexer2.ts(8,23): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/classes/indexMemberDeclarations/privateIndexer2.ts(9,1): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/classes/indexMemberDeclarations/privateIndexer2.ts(4,17): error TS2304: Cannot find name 'string'.
|
||||
tests/cases/conformance/classes/indexMemberDeclarations/privateIndexer2.ts(8,5): error TS2304: Cannot find name 'private'.
|
||||
tests/cases/conformance/classes/indexMemberDeclarations/privateIndexer2.ts(8,16): error TS2304: Cannot find name 'string'.
|
||||
tests/cases/conformance/classes/indexMemberDeclarations/privateIndexer2.ts(8,25): error TS2304: Cannot find name 'string'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/indexMemberDeclarations/privateIndexer2.ts (14 errors) ====
|
||||
==== tests/cases/conformance/classes/indexMemberDeclarations/privateIndexer2.ts (5 errors) ====
|
||||
// private indexers not allowed
|
||||
|
||||
var x = {
|
||||
private [x: string]: string;
|
||||
~
|
||||
!!! error TS1005: ':' expected.
|
||||
~
|
||||
!!! error TS1005: ']' expected.
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
!!! error TS1136: Property assignment expected.
|
||||
~
|
||||
!!! error TS1005: ':' expected.
|
||||
~~~~~~
|
||||
!!! error TS2304: Cannot find name 'string'.
|
||||
}
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
|
||||
var y: {
|
||||
private[x: string]: string;
|
||||
~~~~~~~
|
||||
!!! error TS1131: Property or signature expected.
|
||||
~
|
||||
!!! error TS1005: ']' expected.
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
~~~~~~~
|
||||
!!! error TS2304: Cannot find name 'private'.
|
||||
~~~~~~
|
||||
!!! error TS2304: Cannot find name 'string'.
|
||||
~~~~~~
|
||||
!!! error TS2304: Cannot find name 'string'.
|
||||
}
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
interface I {
|
||||
public [a: string]: number;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
var v = { public foo() { } }
|
||||
@@ -0,0 +1 @@
|
||||
var v = { public get foo() { } }
|
||||
@@ -0,0 +1 @@
|
||||
var v = { foo?() { } }
|
||||
1
tests/cases/compiler/objectLiteralMemberWithoutBlock1.ts
Normal file
1
tests/cases/compiler/objectLiteralMemberWithoutBlock1.ts
Normal file
@@ -0,0 +1 @@
|
||||
var v = { foo(); }
|
||||
Reference in New Issue
Block a user