Skip to content

Commit

Permalink
Revert "feat(47595): allow using private fields in type queries (micr…
Browse files Browse the repository at this point in the history
…osoft#47696)"

This reverts commit 063eaa7.
  • Loading branch information
jakebailey committed May 4, 2022
1 parent f579f33 commit 52ac031
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 130 deletions.
16 changes: 8 additions & 8 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ namespace ts {
initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, ScriptKind.JS);
// Prime the scanner.
nextToken();
const entityName = parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false);
const entityName = parseEntityName(/*allowReservedWords*/ true);
const isInvalid = token() === SyntaxKind.EndOfFileToken && !parseDiagnostics.length;
clearState();
return isInvalid ? entityName : undefined;
Expand Down Expand Up @@ -2829,7 +2829,7 @@ namespace ts {
return createMissingList<T>();
}

function parseEntityName(allowReservedWords: boolean, allowPrivateIdentifiers: boolean, diagnosticMessage?: DiagnosticMessage): EntityName {
function parseEntityName(allowReservedWords: boolean, diagnosticMessage?: DiagnosticMessage): EntityName {
const pos = getNodePos();
let entity: EntityName = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage);
let dotPos = getNodePos();
Expand All @@ -2843,7 +2843,7 @@ namespace ts {
entity = finishNode(
factory.createQualifiedName(
entity,
parseRightSideOfDot(allowReservedWords, allowPrivateIdentifiers) as Identifier
parseRightSideOfDot(allowReservedWords, /* allowPrivateIdentifiers */ false) as Identifier
),
pos
);
Expand Down Expand Up @@ -3028,7 +3028,7 @@ namespace ts {
// TYPES

function parseEntityNameOfTypeReference() {
return parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false, Diagnostics.Type_expected);
return parseEntityName(/*allowReservedWords*/ true, Diagnostics.Type_expected);
}

function parseTypeArgumentsOfTypeReference() {
Expand Down Expand Up @@ -3188,7 +3188,7 @@ namespace ts {
function parseTypeQuery(): TypeQueryNode {
const pos = getNodePos();
parseExpected(SyntaxKind.TypeOfKeyword);
const entityName = parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ true);
const entityName = parseEntityName(/*allowReservedWords*/ true);
// Make sure we perform ASI to prevent parsing the next line's type arguments as part of an instantiation expression.
const typeArguments = !scanner.hasPrecedingLineBreak() ? tryParseTypeArguments() : undefined;
return finishNode(factory.createTypeQueryNode(entityName, typeArguments), pos);
Expand Down Expand Up @@ -7470,7 +7470,7 @@ namespace ts {
function parseModuleReference() {
return isExternalModuleReference()
? parseExternalModuleReference()
: parseEntityName(/*allowReservedWords*/ false, /*allowPrivateIdentifiers*/ false);
: parseEntityName(/*allowReservedWords*/ false);
}

function parseExternalModuleReference() {
Expand Down Expand Up @@ -7743,7 +7743,7 @@ namespace ts {
const pos = getNodePos();
const hasBrace = parseOptional(SyntaxKind.OpenBraceToken);
const p2 = getNodePos();
let entityName: EntityName | JSDocMemberName = parseEntityName(/* allowReservedWords*/ false, /*allowPrivateIdentifiers*/ false);
let entityName: EntityName | JSDocMemberName = parseEntityName(/* allowReservedWords*/ false);
while (token() === SyntaxKind.PrivateIdentifier) {
reScanHashToken(); // rescan #id as # id
nextTokenJSDoc(); // then skip the #
Expand Down Expand Up @@ -8206,7 +8206,7 @@ namespace ts {
// parseEntityName logs an error for non-identifier, so create a MissingNode ourselves to avoid the error
const p2 = getNodePos();
let name: EntityName | JSDocMemberName | undefined = tokenIsIdentifierOrKeyword(token())
? parseEntityName(/*allowReservedWords*/ true, /*allowPrivateIdentifiers*/ false)
? parseEntityName(/*allowReservedWords*/ true)
: undefined;
if (name) {
while (token() === SyntaxKind.PrivateIdentifier) {
Expand Down
21 changes: 0 additions & 21 deletions tests/baselines/reference/privateNameInTypeQuery.errors.txt

This file was deleted.

25 changes: 0 additions & 25 deletions tests/baselines/reference/privateNameInTypeQuery.js

This file was deleted.

28 changes: 0 additions & 28 deletions tests/baselines/reference/privateNameInTypeQuery.symbols

This file was deleted.

34 changes: 0 additions & 34 deletions tests/baselines/reference/privateNameInTypeQuery.types

This file was deleted.

This file was deleted.

0 comments on commit 52ac031

Please sign in to comment.