mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Address code review; better error recovering
This commit is contained in:
parent
4b7d2f2411
commit
e91ef844ed
@ -1487,8 +1487,8 @@ module ts {
|
||||
if (isIdentifier) {
|
||||
let node = <Identifier>createNode(SyntaxKind.Identifier);
|
||||
|
||||
// Set strictModeKind property so that we can report appropriate error later in type checker
|
||||
if (inStrictModeContext() && (token > SyntaxKind.Identifier && token <= SyntaxKind.LastFutureReservedWord)) {
|
||||
// Store original token kind so we can report appropriate error later in type checker
|
||||
if (token >= SyntaxKind.FirstReservedWord && token <= SyntaxKind.LastFutureReservedWord) {
|
||||
node.isKeywordInStrictMode = token;
|
||||
}
|
||||
node.text = internIdentifier(scanner.getTokenValue());
|
||||
@ -4640,6 +4640,7 @@ module ts {
|
||||
case SyntaxKind.ColonToken: // Type Annotation for declaration
|
||||
case SyntaxKind.EqualsToken: // Initializer for declaration
|
||||
case SyntaxKind.QuestionToken: // Not valid, but permitted so that it gets caught later on.
|
||||
case SyntaxKind.AtToken:
|
||||
return true;
|
||||
default:
|
||||
// Covers
|
||||
|
||||
@ -1,35 +1,11 @@
|
||||
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
|
||||
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,5): error TS2304: Cannot find name 'public'.
|
||||
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,12): error TS1005: ';' expected.
|
||||
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,16): error TS1146: Declaration expected.
|
||||
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,17): error TS2304: Cannot find name 'get'.
|
||||
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,21): error TS1005: ';' expected.
|
||||
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,21): error TS2304: Cannot find name 'accessor'.
|
||||
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,32): error TS1005: ';' expected.
|
||||
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(5,1): error TS1128: Declaration or statement expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts (9 errors) ====
|
||||
==== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts (1 errors) ====
|
||||
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
|
||||
|
||||
class C {
|
||||
public @dec get accessor() { return 1; }
|
||||
~~~~~~
|
||||
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
|
||||
~~~~~~
|
||||
!!! error TS2304: Cannot find name 'public'.
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
||||
|
||||
!!! error TS1146: Declaration expected.
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'get'.
|
||||
~~~~~~~~
|
||||
!!! error TS1005: ';' expected.
|
||||
~~~~~~~~
|
||||
!!! error TS2304: Cannot find name 'accessor'.
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
||||
}
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
}
|
||||
@ -6,14 +6,24 @@ class C {
|
||||
}
|
||||
|
||||
//// [decoratorOnClassAccessor3.js]
|
||||
var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) {
|
||||
switch (arguments.length) {
|
||||
case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);
|
||||
case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);
|
||||
case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);
|
||||
}
|
||||
};
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
Object.defineProperty(C.prototype, "accessor", {
|
||||
get: function () { return 1; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, "accessor",
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor")));
|
||||
return C;
|
||||
})();
|
||||
public;
|
||||
get;
|
||||
accessor();
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1,44 +1,11 @@
|
||||
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
|
||||
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,5): error TS2304: Cannot find name 'public'.
|
||||
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,12): error TS1005: ';' expected.
|
||||
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,16): error TS1146: Declaration expected.
|
||||
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,17): error TS2304: Cannot find name 'set'.
|
||||
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,21): error TS1005: ';' expected.
|
||||
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,21): error TS2304: Cannot find name 'accessor'.
|
||||
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,30): error TS2304: Cannot find name 'value'.
|
||||
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,35): error TS1005: ',' expected.
|
||||
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,37): error TS2304: Cannot find name 'number'.
|
||||
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,45): error TS1005: ';' expected.
|
||||
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(5,1): error TS1128: Declaration or statement expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts (12 errors) ====
|
||||
==== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts (1 errors) ====
|
||||
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
|
||||
|
||||
class C {
|
||||
public @dec set accessor(value: number) { }
|
||||
~~~~~~
|
||||
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
|
||||
~~~~~~
|
||||
!!! error TS2304: Cannot find name 'public'.
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
||||
|
||||
!!! error TS1146: Declaration expected.
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'set'.
|
||||
~~~~~~~~
|
||||
!!! error TS1005: ';' expected.
|
||||
~~~~~~~~
|
||||
!!! error TS2304: Cannot find name 'accessor'.
|
||||
~~~~~
|
||||
!!! error TS2304: Cannot find name 'value'.
|
||||
~
|
||||
!!! error TS1005: ',' expected.
|
||||
~~~~~~
|
||||
!!! error TS2304: Cannot find name 'number'.
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
||||
}
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
}
|
||||
@ -6,12 +6,24 @@ class C {
|
||||
}
|
||||
|
||||
//// [decoratorOnClassAccessor6.js]
|
||||
var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) {
|
||||
switch (arguments.length) {
|
||||
case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);
|
||||
case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);
|
||||
case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);
|
||||
}
|
||||
};
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
Object.defineProperty(C.prototype, "accessor", {
|
||||
set: function (value) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, "accessor",
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor")));
|
||||
return C;
|
||||
})();
|
||||
public;
|
||||
set;
|
||||
accessor(value, number);
|
||||
{ }
|
||||
|
||||
@ -1,29 +1,11 @@
|
||||
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
|
||||
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,5): error TS2304: Cannot find name 'public'.
|
||||
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,12): error TS1005: ';' expected.
|
||||
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,16): error TS1146: Declaration expected.
|
||||
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,17): error TS2304: Cannot find name 'method'.
|
||||
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,26): error TS1005: ';' expected.
|
||||
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(5,1): error TS1128: Declaration or statement expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts (7 errors) ====
|
||||
==== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts (1 errors) ====
|
||||
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
|
||||
|
||||
class C {
|
||||
public @dec method() {}
|
||||
~~~~~~
|
||||
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
|
||||
~~~~~~
|
||||
!!! error TS2304: Cannot find name 'public'.
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
||||
|
||||
!!! error TS1146: Declaration expected.
|
||||
~~~~~~
|
||||
!!! error TS2304: Cannot find name 'method'.
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
||||
}
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
}
|
||||
@ -6,11 +6,20 @@ class C {
|
||||
}
|
||||
|
||||
//// [decoratorOnClassMethod3.js]
|
||||
var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) {
|
||||
switch (arguments.length) {
|
||||
case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);
|
||||
case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);
|
||||
case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);
|
||||
}
|
||||
};
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.method = function () { };
|
||||
Object.defineProperty(C.prototype, "method",
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method")));
|
||||
return C;
|
||||
})();
|
||||
public;
|
||||
method();
|
||||
{ }
|
||||
|
||||
@ -1,26 +1,11 @@
|
||||
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
|
||||
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4,5): error TS2304: Cannot find name 'public'.
|
||||
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4,12): error TS1005: ';' expected.
|
||||
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4,16): error TS1146: Declaration expected.
|
||||
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4,17): error TS2304: Cannot find name 'prop'.
|
||||
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(5,1): error TS1128: Declaration or statement expected.
|
||||
|
||||
|
||||
==== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts (6 errors) ====
|
||||
==== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts (1 errors) ====
|
||||
declare function dec(target: any, propertyKey: string): void;
|
||||
|
||||
class C {
|
||||
public @dec prop;
|
||||
~~~~~~
|
||||
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
|
||||
~~~~~~
|
||||
!!! error TS2304: Cannot find name 'public'.
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
||||
|
||||
!!! error TS1146: Declaration expected.
|
||||
~~~~
|
||||
!!! error TS2304: Cannot find name 'prop'.
|
||||
}
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
}
|
||||
@ -6,10 +6,18 @@ class C {
|
||||
}
|
||||
|
||||
//// [decoratorOnClassProperty3.js]
|
||||
var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) {
|
||||
switch (arguments.length) {
|
||||
case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);
|
||||
case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);
|
||||
case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);
|
||||
}
|
||||
};
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, "prop");
|
||||
return C;
|
||||
})();
|
||||
public;
|
||||
prop;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user