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

feat(es/parser): Make error message helpful #6535

Merged
merged 17 commits into from Nov 29, 2022
Expand Up @@ -7,8 +7,7 @@
//! 2 | }
//! `----
//!
//! x Unexpected token `yield`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 | function f(yield = yield) {
//! : ^^^^^
Expand Down
Expand Up @@ -7,8 +7,7 @@
//! 2 | }
//! `----
//!
//! x Unexpected token `yield`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 | function f(yield = yield) {
//! : ^^^^^
Expand Down
@@ -1,7 +1,6 @@
//// [FunctionDeclaration8_es6.ts]
//!
//! x Unexpected token `yield`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,----
//! 1 | var v = { [yield]: foo }
//! : ^^^^^
Expand Down
@@ -1,7 +1,6 @@
//// [FunctionDeclaration8_es6.ts]
//!
//! x Unexpected token `yield`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,----
//! 1 | var v = { [yield]: foo }
//! : ^^^^^
Expand Down
@@ -1,7 +1,6 @@
//// [YieldExpression1_es6.ts]
//!
//! x Unexpected token `yield`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,----
//! 1 | yield;
//! : ^^^^^
Expand Down
@@ -1,7 +1,6 @@
//// [YieldExpression1_es6.ts]
//!
//! x Unexpected token `yield`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,----
//! 1 | yield;
//! : ^^^^^
Expand Down
@@ -1,7 +1,6 @@
//// [YieldExpression8_es6.ts]
//!
//! x Unexpected token `yield`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 | yield(foo);
//! : ^^^^^
Expand Down
@@ -1,7 +1,6 @@
//// [YieldExpression8_es6.ts]
//!
//! x Unexpected token `yield`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 | yield(foo);
//! : ^^^^^
Expand Down
@@ -1,7 +1,6 @@
//// [YieldStarExpression1_es6.ts]
//!
//! x Unexpected token `yield`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,----
//! 1 | yield * [];
//! : ^^^^^
Expand Down
@@ -1,7 +1,6 @@
//// [YieldStarExpression1_es6.ts]
//!
//! x Unexpected token `yield`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,----
//! 1 | yield * [];
//! : ^^^^^
Expand Down
Expand Up @@ -10,8 +10,7 @@
//! 5 | I // This should be the identifier 'I'
//! `----
//!
//! x Unexpected token `interface`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string,
//! | regexp, ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 |
//! 2 | var interface: number, I: string;
Expand Down
Expand Up @@ -10,8 +10,7 @@
//! 5 | I // This should be the identifier 'I'
//! `----
//!
//! x Unexpected token `interface`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string,
//! | regexp, ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 |
//! 2 | var interface: number, I: string;
Expand Down
Expand Up @@ -10,8 +10,7 @@
//! 5 | {} // This should be a block body
//! `----
//!
//! x Unexpected token `interface`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string,
//! | regexp, ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 |
//! 2 | function f(interface: number, I: string) {
Expand Down
Expand Up @@ -10,8 +10,7 @@
//! 5 | {} // This should be a block body
//! `----
//!
//! x Unexpected token `interface`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string,
//! | regexp, ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 |
//! 2 | function f(interface: number, I: string) {
Expand Down
Expand Up @@ -10,8 +10,7 @@
//! 5 | interface // This should be the identifier 'interface'
//! `----
//!
//! x Unexpected token `interface`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string,
//! | regexp, ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[2:1]
//! 2 | var interface: number, I: string;
//! 3 |
Expand Down
Expand Up @@ -10,8 +10,7 @@
//! 5 | interface // This should be the identifier 'interface'
//! `----
//!
//! x Unexpected token `interface`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string,
//! | regexp, ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[2:1]
//! 2 | var interface: number, I: string;
//! 3 |
Expand Down
Expand Up @@ -12,8 +12,7 @@
//! 8 | var BOOLEAN2 = delete ;
//! `----
//!
//! x Unexpected token `;`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[2:1]
//! 2 | var ANY;
//! 3 |
Expand All @@ -37,8 +36,7 @@
//! 8 | var BOOLEAN2 = delete ;
//! `----
//!
//! x Unexpected token `;`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[5:1]
//! 5 | var BOOLEAN1 = ANY delete ; //expect error
//! 6 |
Expand Down
Expand Up @@ -12,8 +12,7 @@
//! 8 | var BOOLEAN2 = delete ;
//! `----
//!
//! x Unexpected token `;`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[2:1]
//! 2 | var ANY;
//! 3 |
Expand All @@ -37,8 +36,7 @@
//! 8 | var BOOLEAN2 = delete ;
//! `----
//!
//! x Unexpected token `;`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[5:1]
//! 5 | var BOOLEAN1 = ANY delete ; //expect error
//! 6 |
Expand Down
@@ -1,7 +1,6 @@
//// [generatorTypeCheck32.ts]
//!
//! x Unexpected token `yield`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 | var s: string;
//! 2 | var f: () => number = () => yield s;
Expand Down
@@ -1,7 +1,6 @@
//// [generatorTypeCheck32.ts]
//!
//! x Unexpected token `yield`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 | var s: string;
//! 2 | var f: () => number = () => yield s;
Expand Down
@@ -1,7 +1,6 @@
//// [generatorTypeCheck39.ts]
//!
//! x Unexpected token `@`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[2:1]
//! 2 | return y => { };
//! 3 | }
Expand Down
@@ -1,7 +1,6 @@
//// [generatorTypeCheck39.ts]
//!
//! x Unexpected token `@`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[2:1]
//! 2 | return y => { };
//! 3 | }
Expand Down
@@ -1,7 +1,6 @@
//// [generatorTypeCheck61.ts]
//!
//! x Unexpected token `@`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 | function * g() {
//! 2 | @(yield 0)
Expand Down
@@ -1,7 +1,6 @@
//// [generatorTypeCheck61.ts]
//!
//! x Unexpected token `@`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 | function * g() {
//! 2 | @(yield 0)
Expand Down
@@ -1,7 +1,6 @@
//// [logicalNotOperatorInvalidOperations.ts]
//!
//! x Unexpected token `;`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[8:1]
//! 8 | var BOOLEAN2 = !b + b;
//! 9 |
Expand Down
@@ -1,7 +1,6 @@
//// [logicalNotOperatorInvalidOperations.ts]
//!
//! x Unexpected token `;`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[8:1]
//! 8 | var BOOLEAN2 = !b + b;
//! 9 |
Expand Down
@@ -1,7 +1,6 @@
//// [parserComputedPropertyName37.ts]
//!
//! x Unexpected token `public`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 | var v = {
//! 2 | [public]: 0
Expand Down
@@ -1,7 +1,6 @@
//// [parserComputedPropertyName37.ts]
//!
//! x Unexpected token `public`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 | var v = {
//! 2 | [public]: 0
Expand Down
@@ -1,7 +1,6 @@
//// [parserInterfaceDeclaration3.ts]
//!
//! x Unexpected token `public`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 | public interface I {
//! : ^^^^^^
Expand Down
@@ -1,7 +1,6 @@
//// [parserInterfaceDeclaration3.ts]
//!
//! x Unexpected token `public`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp,
//! | ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 | public interface I {
//! : ^^^^^^
Expand Down
Expand Up @@ -10,8 +10,7 @@
//! 6 | private[key] = value;
//! `----
//!
//! x Unexpected token `private`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string,
//! | regexp, ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[3:1]
//! 3 | "set": function (key, value) {
//! 4 |
Expand Down
Expand Up @@ -10,8 +10,7 @@
//! 6 | private[key] = value;
//! `----
//!
//! x Unexpected token `private`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string,
//! | regexp, ` for template literal, (, or an identifier
//! x Expression expected
//! ,-[3:1]
//! 3 | "set": function (key, value) {
//! 4 |
Expand Down
Expand Up @@ -11,8 +11,7 @@
//! 12 | <>eof // Error
//! `----
//!
//! x Unexpected token `>`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[9:1]
//! 9 |
//! 10 | <>hi</div> // Error
Expand Down
Expand Up @@ -11,8 +11,7 @@
//! 12 | <>eof // Error
//! `----
//!
//! x Unexpected token `>`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[9:1]
//! 9 |
//! 10 | <>hi</div> // Error
Expand Down
Expand Up @@ -12,8 +12,7 @@
//! 7 | var ANY1 = typeof ;
//! `----
//!
//! x Unexpected token `;`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 | // Unary operator typeof
//! 2 |
Expand All @@ -25,8 +24,7 @@
//! 7 | var ANY1 = typeof ;
//! `----
//!
//! x Unexpected token `;`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[4:1]
//! 4 | var ANY = ANY typeof ; //expect error
//! 5 |
Expand Down
Expand Up @@ -12,8 +12,7 @@
//! 7 | var ANY1 = typeof ;
//! `----
//!
//! x Unexpected token `;`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 | // Unary operator typeof
//! 2 |
Expand All @@ -25,8 +24,7 @@
//! 7 | var ANY1 = typeof ;
//! `----
//!
//! x Unexpected token `;`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[4:1]
//! 4 | var ANY = ANY typeof ; //expect error
//! 5 |
Expand Down
Expand Up @@ -12,8 +12,7 @@
//! 7 | var ANY1 = void ;
//! `----
//!
//! x Unexpected token `;`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[1:1]
//! 1 | // Unary operator void
//! 2 |
Expand All @@ -25,8 +24,7 @@
//! 7 | var ANY1 = void ;
//! `----
//!
//! x Unexpected token `;`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, `
//! | for template literal, (, or an identifier
//! x Expression expected
//! ,-[4:1]
//! 4 | var ANY = ANY void ; //expect error
//! 5 |
Expand Down