mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
fix(54954): Javascript Intellisense adding "this." to function declaration (#55119)
This commit is contained in:
parent
607d96f6df
commit
d045f18928
@ -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) {
|
||||
|
||||
@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
14
tests/cases/fourslash/completionsAfterPropertyNameInClass.ts
Normal file
14
tests/cases/fourslash/completionsAfterPropertyNameInClass.ts
Normal 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,
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user