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

add class.hasInstance proposal (Stage 1) support #13959

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
23a0380
feat: brand-check init
Nov 10, 2021
0e190fa
feat: update brank check test
Nov 13, 2021
54d8fbe
fix: add exception handing
Nov 13, 2021
e352fe1
feat: fixed basic list
Feb 16, 2022
e7b7f2b
feat: add return case with any statement
Feb 18, 2022
118f6a1
feat: add ast/spec.md
Feb 22, 2022
27cc74e
feat: add plugin class brand check
Mar 14, 2022
b49580c
fix: Remove unused comments
Mar 14, 2022
7bf5484
Merge branch 'main' into feat/classhasintance
Mar 14, 2022
dba8628
feat: update test case
Mar 22, 2022
8068917
feat: update mr
Mar 24, 2022
669c512
Merge branch 'main' into feat/classhasintance
Mar 24, 2022
c7d09ae
Merge branch 'fix/pr' into feat/classhasintance
Mar 24, 2022
b8666a3
feat: update yarn check
Mar 24, 2022
5df87fa
fixed: delete unuse comment
Mar 24, 2022
2070c6e
fixed: class decorators
Mar 24, 2022
61220d3
Merge branch 'main' into feat/classhasintance
Mar 28, 2022
173cb35
Update packages/babel-generator/src/generators/expressions.ts
YuriTu Mar 28, 2022
2f9e7f4
Merge branch 'feat/classhasintance' of github.com:YuriTu/babel into f…
Mar 28, 2022
a3a5b72
fixed: pkg type error
Mar 28, 2022
2cfdd98
fixed: adjust token consumption
Mar 28, 2022
8adfc8b
feat: update tokenizer hasinstance
Apr 11, 2022
c0c2599
feat: update comments test case
Apr 12, 2022
d58414d
having diffcult when adding case
Apr 15, 2022
168fa02
fix: resolve parser options name
Apr 15, 2022
4e73912
fix: update token comsumption time
Apr 18, 2022
966889d
fix: update generator test case
Apr 18, 2022
d32b606
fix: update arguments case
Apr 18, 2022
e8ca303
Update packages/babel-parser/src/parser/expression.js
YuriTu Apr 19, 2022
9bc5e71
Update packages/babel-parser/ast/spec.md
YuriTu Apr 19, 2022
f82f9fd
fix: remove unused expression and snap file
Apr 19, 2022
c32e0c7
Update packages/babel-parser/src/parser/expression.js
YuriTu Apr 19, 2022
8c4ba97
Merge branch 'feat/classhasintance' of github.com:YuriTu/babel into f…
Apr 19, 2022
c115075
fix: error message
Apr 19, 2022
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
11 changes: 6 additions & 5 deletions packages/babel-parser/src/parser/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -903,8 +903,8 @@ export default class ExpressionParser extends LValParser {
this.expectPlugin("classBrandCheck");
return this.parseClassHasInstanceExpression(
node,
this.startPos,
this.startLoc,
this.state.startPos,
this.state.startLoc,
);
} else {
throw this.raise(Errors.UnexpectedToken, { at: node });
Expand All @@ -919,10 +919,11 @@ export default class ExpressionParser extends LValParser {
this.next(); // eat `(`
YuriTu marked this conversation as resolved.
Show resolved Hide resolved
const node = this.startNodeAt(startPos, startLoc);
const argus = this.parseCallExpressionArguments(tt.parenR);
YuriTu marked this conversation as resolved.
Show resolved Hide resolved
if (argus.length !== 1) {
this.raise(Errors.InvalidArguments, { at: startLoc });
if (argus.length !== 1 || (argus[0] && argus[0].type === "SpreadElement")) {
YuriTu marked this conversation as resolved.
Show resolved Hide resolved
throw this.raise(Errors.InvalidArguments, {
at: this.state.lastTokStartLoc,
});
}

node.instance = argus[0];

this.state.stop = true;
YuriTu marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"throws": "This experimental syntax requires enabling the parser plugin: \"classBrandCheck\". (3:14)",
"plugins": []
"throws": "SyntaxError: Invalid Arguments. (3:26)",
"plugins": ["classBrandCheck"]
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Foo {
bar(foo) {
class.hasInstance(...foo)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"throws": "SyntaxError: Invalid Arguments. (3:32)",
"plugins": ["classBrandCheck"]
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Foo {
bar(foo,bar) {
class.hasInstance(foo,...bar)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"throws": "SyntaxError: Invalid Arguments. (3:36)",
"plugins": ["classBrandCheck"]
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Foo {
bar(foo,bar) {
class.hasInstance(foo,bar)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"throws": "SyntaxError: Invalid Arguments. (3:33)",
"plugins": ["classBrandCheck"]
}

This file was deleted.

This file was deleted.