af689cc5d5
* es private fields in in (#52) add support for the 'private-fields-in-in' TC39 proposal Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [fixup] include inToken when walking forEachChild(node, cb) * [squash] re-accept lib definition baseline changes * [squash] reduce if/else to ternary Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] drop 'originalName' and rename parameter instead Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] extend spelling suggestion to all privateIdentifiers Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] revert the added lexical spelling suggestions logic Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] update baseline Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] inline variable as per PR suggestion Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] test targets both esnext and es2020 as per PR comment Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * switch to using a binary expression Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] PrivateIdentifier now extends PrimaryExpression Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] accept public api baseline changes Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] classPrivateFieldInHelper now has documentation Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] type-check now follows existing in-expression path Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] parser now follows existing binaryExpression path Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] correct typo in comment Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] no longer use esNext flag Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] swap 'reciever, state' helper params Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] remove change to parenthesizerRules Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] apply suggested changes to checker Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] remove need for assertion in fixSpelling Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] improve comment hint in test Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] fix comment typos Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] add flow-test for Foo | FooSub | Bar Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] add checkExternalEmitHelpers call and new test case Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] simplify and correct parser Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] move most of the added checker logic to expression level Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] always error when privateId could not be resolved Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] reword comment Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] fix codeFixSpelling test Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] do less work Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * store symbol by priateId not binaryExpression Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * moved parsePrivateIdentifier into parsePrimaryExpression Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] checkInExpressionn bails out early on silentNeverType Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] more detailed error messages Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] resolves conflict in diagnosticMessages.json Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] update baseline for importHelpersES6 Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] remove redundent if and comment from parser Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] split up grammar/check/symbolLookup Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com> * [squash] reword message for existing left side of in-expression error Signed-off-by: Ashley Claymore <acutmore@users.noreply.github.com>
142 lines
2.8 KiB
Plaintext
142 lines
2.8 KiB
Plaintext
=== tests/cases/conformance/classes/members/privateNames/privateNameInInExpressionTransform.ts ===
|
|
class Foo {
|
|
>Foo : Foo
|
|
|
|
#field = 1;
|
|
>#field : number
|
|
>1 : 1
|
|
|
|
#method() {}
|
|
>#method : () => void
|
|
|
|
static #staticField= 2;
|
|
>#staticField : number
|
|
>2 : 2
|
|
|
|
static #staticMethod() {}
|
|
>#staticMethod : () => void
|
|
|
|
check(v: any) {
|
|
>check : (v: any) => void
|
|
>v : any
|
|
|
|
#field in v; // expect Foo's 'field' WeakMap
|
|
>#field in v : boolean
|
|
>#field : any
|
|
>v : any
|
|
|
|
#method in v; // expect Foo's 'instances' WeakSet
|
|
>#method in v : boolean
|
|
>#method : any
|
|
>v : any
|
|
|
|
#staticField in v; // expect Foo's constructor
|
|
>#staticField in v : boolean
|
|
>#staticField : any
|
|
>v : any
|
|
|
|
#staticMethod in v; // expect Foo's constructor
|
|
>#staticMethod in v : boolean
|
|
>#staticMethod : any
|
|
>v : any
|
|
}
|
|
precedence(v: any) {
|
|
>precedence : (v: any) => void
|
|
>v : any
|
|
|
|
// '==' and '||' have lower precedence than 'in'
|
|
// 'in' naturally has same precedence as 'in'
|
|
// '<<' has higher precedence than 'in'
|
|
|
|
v == #field in v || v; // Good precedence: (v == (#field in v)) || v
|
|
>v == #field in v || v : any
|
|
>v == #field in v : boolean
|
|
>v : any
|
|
>#field in v : boolean
|
|
>#field : any
|
|
>v : any
|
|
>v : any
|
|
|
|
v << #field in v << v; // Good precedence (SyntaxError): (v << #field) in (v << v)
|
|
>v << #field in v << v : boolean
|
|
>v << #field : number
|
|
>v : any
|
|
>v << v : number
|
|
>v : any
|
|
>v : any
|
|
|
|
v << #field in v == v; // Good precedence (SyntaxError): ((v << #field) in v) == v
|
|
>v << #field in v == v : boolean
|
|
>v << #field in v : boolean
|
|
>v << #field : number
|
|
>v : any
|
|
>v : any
|
|
>v : any
|
|
|
|
v == #field in v in v; // Good precedence: v == ((#field in v) in v)
|
|
>v == #field in v in v : boolean
|
|
>v : any
|
|
>#field in v in v : boolean
|
|
>#field in v : boolean
|
|
>#field : any
|
|
>v : any
|
|
>v : any
|
|
|
|
#field in v && #field in v; // Good precedence: (#field in v) && (#field in v)
|
|
>#field in v && #field in v : boolean
|
|
>#field in v : boolean
|
|
>#field : any
|
|
>v : any
|
|
>#field in v : boolean
|
|
>#field : any
|
|
>v : Foo
|
|
}
|
|
invalidLHS(v: any) {
|
|
>invalidLHS : (v: any) => void
|
|
>v : any
|
|
|
|
'prop' in v = 10;
|
|
>'prop' in v : boolean
|
|
>'prop' : "prop"
|
|
>v : any
|
|
>10 : 10
|
|
|
|
#field in v = 10;
|
|
>#field in v : boolean
|
|
>#field : any
|
|
>v : any
|
|
>10 : 10
|
|
}
|
|
}
|
|
|
|
class Bar {
|
|
>Bar : Bar
|
|
|
|
#field = 1;
|
|
>#field : number
|
|
>1 : 1
|
|
|
|
check(v: any) {
|
|
>check : (v: any) => void
|
|
>v : any
|
|
|
|
#field in v; // expect Bar's 'field' WeakMap
|
|
>#field in v : boolean
|
|
>#field : any
|
|
>v : any
|
|
}
|
|
}
|
|
|
|
function syntaxError(v: Foo) {
|
|
>syntaxError : (v: Foo) => boolean
|
|
>v : Foo
|
|
|
|
return #field in v; // expect `return in v` so runtime will have a syntax error
|
|
>#field in v : boolean
|
|
>#field : any
|
|
>v : Foo
|
|
}
|
|
|
|
export { }
|
|
|