Use ReferenceIdentifier instead of Identifier in FlowQualifiedTypeIdentifier
MODIFY
packages/@romejs/cli-diagnostics/buildMessageCodeFrame.ts
packages/@romejs/cli-diagnostics/buildMessageCodeFrame.ts
@@ -26,6 +26,7 @@ import {
coerce0to1,
number1Neg1,
} from '@romejs/ob1';
+import {stripMarkupTags} from '@romejs/string-markup';
export default function buildMessageCodeFrame(
sourceText: string,
@@ -154,9 +155,11 @@ export default function buildMessageCodeFrame(
CODE_FRAME_INDENT.length;
// If what the marker is highlighting equals the marker message then it's redundant so don't show the message
- if (markerMessage !== '' && start.line === end.line) {
+ if (markerMessage !== '') {
const text = sourceText.slice(get0(start.index), get0(end.index));
- if (cleanEquivalentString(text) === cleanEquivalentString(markerMessage)) {
+ if (cleanEquivalentString(text) === cleanEquivalentString(stripMarkupTags(
+ markerMessage,
+ ))) {
markerMessage = '';
}
}

MODIFY
packages/@romejs/js-analysis/evaluators/flow/FlowGenericTypeAnnotation.ts
packages/@romejs/js-analysis/evaluators/flow/FlowGenericTypeAnnotation.ts
import {Scope} from '../../scopes';
import {
AnyNode,
- Identifier,
+ ReferenceIdentifier,
FlowQualifiedTypeIdentifier,
FlowGenericTypeAnnotation,
flowGenericTypeAnnotation,
} from '@romejs/js-ast';
import GenericT from '../../types/GenericT';
-function getName(node: Identifier | FlowQualifiedTypeIdentifier): string {
- if (node.type === 'Identifier') {
+function getName(node: ReferenceIdentifier | FlowQualifiedTypeIdentifier): string {
+ if (node.type === 'ReferenceIdentifier') {
return node.name;
} else {
return `${getName(node.id)}.${getName(node.qualification)}`;

MODIFY
packages/@romejs/js-ast/flow/FlowGenericTypeAnnotation.ts
packages/@romejs/js-ast/flow/FlowGenericTypeAnnotation.ts
import {
JSNodeBase,
- Identifier,
+ ReferenceIdentifier,
FlowQualifiedTypeIdentifier,
FlowTypeParameterInstantiation,
} from '../index';
@@ -17,7 +17,7 @@ export type FlowGenericTypeAnnotation =
& JSNodeBase
& {
type: 'FlowGenericTypeAnnotation';
- id: Identifier | FlowQualifiedTypeIdentifier;
+ id: ReferenceIdentifier | FlowQualifiedTypeIdentifier;
typeParameters?: FlowTypeParameterInstantiation;
};

MODIFY
packages/@romejs/js-ast/flow/FlowInterfaceExtends.ts
packages/@romejs/js-ast/flow/FlowInterfaceExtends.ts
import {
JSNodeBase,
- Identifier,
+ ReferenceIdentifier,
FlowTypeParameterInstantiation,
FlowQualifiedTypeIdentifier,
} from '../index';
@@ -17,7 +17,7 @@ export type FlowInterfaceExtends =
& JSNodeBase
& {
type: 'FlowInterfaceExtends';
- id: Identifier | FlowQualifiedTypeIdentifier;
+ id: ReferenceIdentifier | FlowQualifiedTypeIdentifier;
typeParameters?: FlowTypeParameterInstantiation;
};

MODIFY
packages/@romejs/js-ast/flow/FlowQualifiedTypeIdentifier.ts
packages/@romejs/js-ast/flow/FlowQualifiedTypeIdentifier.ts
* LICENSE file in the root directory of this source tree.
*/
-import {JSNodeBase, Identifier} from '../index';
+import {JSNodeBase, ReferenceIdentifier, Identifier} from '../index';
import {createBuilder} from '../utils';
export type FlowQualifiedTypeIdentifier =
@@ -13,7 +13,7 @@ export type FlowQualifiedTypeIdentifier =
& {
type: 'FlowQualifiedTypeIdentifier';
id: Identifier;
- qualification: Identifier | FlowQualifiedTypeIdentifier;
+ qualification: ReferenceIdentifier | FlowQualifiedTypeIdentifier;
};
export const flowQualifiedTypeIdentifier = createBuilder<

MODIFY
packages/@romejs/js-parser/parser/flow.ts
packages/@romejs/js-parser/parser/flow.ts
@@ -43,6 +43,7 @@ import {
FlowObjectTypeInternalSlot,
FlowObjectTypePropertyKey,
FlowObjectTypePropertyKind,
+ ReferenceIdentifier,
FlowObjectTypeSpreadProperty,
FlowFunctionTypeAnnotation,
FlowFunctionTypeParam,
@@ -81,6 +82,7 @@ import {
} from './index';
import {get0} from '@romejs/ob1';
import {descriptions} from '@romejs/diagnostics';
+import {parseReferenceIdentifier} from './expression';
const primitiveTypes = [
'any',
@@ -166,7 +168,7 @@ export function parseFlowTypeParameterInstantiationCallOrNew(
function parseFlowTypeOrImplicitInstantiation(parser: JSParser): AnyFlowPrimary {
if (parser.state.tokenType === tt.name && parser.state.tokenValue === '_') {
const startPos = parser.state.startPos;
- const node = parseIdentifier(parser);
+ const node = parseReferenceIdentifier(parser);
return parseFlowGenericType(parser, startPos, node);
} else {
return parseFlowType(parser);
@@ -1305,10 +1307,10 @@ function flowObjectTypeSemicolon(parser: JSParser): void {
function parseFlowQualifiedTypeIdentifier(
parser: JSParser,
start: Position = parser.getPosition(),
- id?: Identifier,
-): Identifier | FlowQualifiedTypeIdentifier {
- let node: Identifier | FlowQualifiedTypeIdentifier = id === undefined
- ? parseIdentifier(parser) : id;
+ id?: ReferenceIdentifier,
+): ReferenceIdentifier | FlowQualifiedTypeIdentifier {
+ let node: ReferenceIdentifier | FlowQualifiedTypeIdentifier = id === undefined
+ ? parseReferenceIdentifier(parser) : id;
while (parser.eat(tt.dot)) {
const id = parseIdentifier(parser);
@@ -1325,7 +1327,7 @@ function parseFlowQualifiedTypeIdentifier(
function parseFlowGenericType(
parser: JSParser,
start: Position,
- _id: Identifier,
+ _id: ReferenceIdentifier,
): FlowGenericTypeAnnotation | FlowGenericTypeAnnotation {
let typeParameters = undefined;
const id = parseFlowQualifiedTypeIdentifier(parser, start, _id);
@@ -1493,7 +1495,10 @@ function flowIdentToTypeAnnotation(
default:
checkNotUnderscore(parser, id);
- return parseFlowGenericType(parser, start, id);
+ return parseFlowGenericType(parser, start, toReferenceIdentifier(
+ parser,
+ id,
+ ));
}
}

Use ReferenceIdentifier instead of Identifier in FlowQualifiedTypeIdentifier