fix(54954): Javascript Intellisense adding "this." to function declaration (#55119)

This commit is contained in:
Oleksandr T 2023-08-04 01:57:51 +03:00 committed by GitHub
parent 607d96f6df
commit d045f18928
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 265 additions and 0 deletions

View File

@ -5298,6 +5298,11 @@ function tryGetObjectTypeDeclarationCompletionContainer(sourceFile: SourceFile,
return cls;
}
break;
case SyntaxKind.PrivateIdentifier:
if (tryCast(location.parent, isPropertyDeclaration)) {
return findAncestor(location, isClassLike);
}
break;
case SyntaxKind.Identifier: {
const originalKeywordKind = identifierToKeywordKind(location as Identifier);
if (originalKeywordKind) {

View File

@ -0,0 +1,246 @@
=== /a.js ===
// class C1 {
// async #fo
// ^
// | ----------------------------------------------------------------------
// | accessor
// | async
// | constructor
// | get
// | set
// | static
// | (warning) C1
// | (warning) C2
// | (warning) fo
// | ----------------------------------------------------------------------
// }
// class C2 {
// async fo
// ^^
// | ----------------------------------------------------------------------
// | accessor
// | async
// | constructor
// | get
// | set
// | static
// | (warning) C1
// | (warning) C2
// | ----------------------------------------------------------------------
// }
[
{
"marker": {
"fileName": "/a.js",
"position": 24,
"name": "a"
},
"item": {
"flags": 0,
"isGlobalCompletion": false,
"isMemberCompletion": true,
"isNewIdentifierLocation": true,
"entries": [
{
"name": "accessor",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "accessor",
"kind": "keyword"
}
]
},
{
"name": "async",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "async",
"kind": "keyword"
}
]
},
{
"name": "constructor",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "constructor",
"kind": "keyword"
}
]
},
{
"name": "get",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "get",
"kind": "keyword"
}
]
},
{
"name": "set",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "set",
"kind": "keyword"
}
]
},
{
"name": "static",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "static",
"kind": "keyword"
}
]
},
{
"name": "C1",
"kind": "warning",
"kindModifiers": "",
"sortText": "18",
"isFromUncheckedFile": true
},
{
"name": "C2",
"kind": "warning",
"kindModifiers": "",
"sortText": "18",
"isFromUncheckedFile": true
},
{
"name": "fo",
"kind": "warning",
"kindModifiers": "",
"sortText": "18",
"isFromUncheckedFile": true
}
]
}
},
{
"marker": {
"fileName": "/a.js",
"position": 50,
"name": "b"
},
"item": {
"flags": 0,
"isGlobalCompletion": false,
"isMemberCompletion": true,
"isNewIdentifierLocation": true,
"optionalReplacementSpan": {
"start": 48,
"length": 2
},
"entries": [
{
"name": "accessor",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "accessor",
"kind": "keyword"
}
]
},
{
"name": "async",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "async",
"kind": "keyword"
}
]
},
{
"name": "constructor",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "constructor",
"kind": "keyword"
}
]
},
{
"name": "get",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "get",
"kind": "keyword"
}
]
},
{
"name": "set",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "set",
"kind": "keyword"
}
]
},
{
"name": "static",
"kind": "keyword",
"kindModifiers": "",
"sortText": "15",
"displayParts": [
{
"text": "static",
"kind": "keyword"
}
]
},
{
"name": "C1",
"kind": "warning",
"kindModifiers": "",
"sortText": "18",
"isFromUncheckedFile": true
},
{
"name": "C2",
"kind": "warning",
"kindModifiers": "",
"sortText": "18",
"isFromUncheckedFile": true
}
]
}
}
]

View File

@ -0,0 +1,14 @@
/// <reference path="fourslash.ts" />
// @allowJs: true
// @filename: /a.js
////class C1 {
//// async #fo/*a*/
////}
////class C2 {
//// async fo/*b*/
////}
verify.baselineCompletions({
includeInsertTextCompletions: true,
});