Skip to content

Commit 3008520

Browse files
authored
Merge pull request #11395 from Microsoft/completionEntry
Add missing check in javascript file for valid identifier when creating completion entry from symbol
2 parents 9852c85 + 1e0e020 commit 3008520

File tree

2 files changed

+72
-1
lines changed

2 files changed

+72
-1
lines changed

src/services/completions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace ts.Completions {
2424
const entries: CompletionEntry[] = [];
2525

2626
if (isSourceFileJavaScript(sourceFile)) {
27-
const uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ false);
27+
const uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true);
2828
addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames));
2929
}
3030
else {
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// @allowjs: true
4+
5+
// @Filename: test.js
6+
////interface Symbol {
7+
//// /** Returns a string representation of an object. */
8+
//// toString(): string;
9+
10+
//// /** Returns the primitive value of the specified object. */
11+
//// valueOf(): Object;
12+
////}
13+
14+
////interface SymbolConstructor {
15+
//// /**
16+
//// * A reference to the prototype.
17+
//// */
18+
//// readonly prototype: Symbol;
19+
20+
//// /**
21+
//// * Returns a new unique Symbol value.
22+
//// * @param description Description of the new Symbol object.
23+
//// */
24+
//// (description?: string | number): symbol;
25+
26+
//// /**
27+
//// * Returns a Symbol object from the global symbol registry matching the given key if found.
28+
//// * Otherwise, returns a new symbol with this key.
29+
//// * @param key key to search for.
30+
//// */
31+
//// for(key: string): symbol;
32+
33+
//// /**
34+
//// * Returns a key from the global symbol registry matching the given Symbol if found.
35+
//// * Otherwise, returns a undefined.
36+
//// * @param sym Symbol to find the key for.
37+
//// */
38+
//// keyFor(sym: symbol): string | undefined;
39+
////}
40+
41+
////declare var Symbol: SymbolConstructor;/// <reference path="lib.es2015.symbol.d.ts" />
42+
43+
////interface SymbolConstructor {
44+
//// /**
45+
//// * A method that determines if a constructor object recognizes an object as one of the
46+
//// * constructor’s instances. Called by the semantics of the instanceof operator.
47+
//// */
48+
//// readonly hasInstance: symbol;
49+
////}
50+
51+
////interface Function {
52+
//// /**
53+
//// * Determines whether the given value inherits from this function if this function was used
54+
//// * as a constructor function.
55+
//// *
56+
//// * A constructor function can control which objects are recognized as its instances by
57+
//// * 'instanceof' by overriding this method.
58+
//// */
59+
//// [Symbol.hasInstance](value: any): boolean;
60+
////}
61+
62+
////interface SomeInterface {
63+
//// (value: number): any;
64+
////}
65+
66+
////var _ : SomeInterface;
67+
////_./**/
68+
69+
goTo.marker();
70+
71+
verify.not.completionListContains("[Symbol.hasInstance]");

0 commit comments

Comments
 (0)