From 65e3c87d2f6b8017265bd455265056b06bb0e1db Mon Sep 17 00:00:00 2001 From: charburgx Date: Fri, 28 Oct 2022 22:18:54 -0500 Subject: [PATCH] feat: support jsx components --- package.json | 1 + packages/api/src/localization.ts | 14 +- packages/api/src/localizedTree.ts | 29 +- packages/api/src/objectUtil.ts | 11 + packages/api/src/tree.ts | 13 + packages/api/src/types.ts | 4 +- packages/api/src/util.ts | 8 +- .../src/view/typeTreeView.ts | 34 +- packages/typescript-plugin/src/index.ts | 2 +- .../jsxFunctionComponent.localized.tree | 2531 ++++++++++++++++ .../reference/jsxFunctionComponent.tree | 2667 +++++++++++++++++ tests/cases/jsxFunctionComponent.tsx | 5 + tests/lib/baselineGenerators.ts | 2 + tests/lib/baselines.ts | 8 +- tsconfig.json | 4 +- yarn.lock | 24 + 16 files changed, 5330 insertions(+), 27 deletions(-) create mode 100644 tests/baselines/reference/jsxFunctionComponent.localized.tree create mode 100644 tests/baselines/reference/jsxFunctionComponent.tree create mode 100644 tests/cases/jsxFunctionComponent.tsx diff --git a/package.json b/package.json index 4ac287d..dfd01a6 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "@types/glob": "^8.0.0", "@types/mocha": "^10.0.0", "@types/node": "^18.8.0", + "@types/react": "^18.0.24", "@typescript-eslint/eslint-plugin": "^5.40.1", "@typescript-eslint/parser": "^5.40.1", "eslint": "^8.26.0", diff --git a/packages/api/src/localization.ts b/packages/api/src/localization.ts index 58d9440..5d33ef1 100644 --- a/packages/api/src/localization.ts +++ b/packages/api/src/localization.ts @@ -15,7 +15,10 @@ export const PrimitiveKindText: Record = { unknown: "unknown", } -export const KindText: Record = { +export const KindText: Record< + LocalizableKind | "method" | "jsx_component", + string +> = { bigint_literal: "$1n", boolean_literal: "$1", enum_literal: "enum", @@ -42,16 +45,20 @@ export const KindText: Record = { class: "class", interface: "interface", method: "method", + jsx_component: "component", } export function getKindText( kind: LocalizableKind, - { insideClassOrInterface }: { insideClassOrInterface?: boolean } = {}, + { + insideClassOrInterface, + isJSXElement, + }: { insideClassOrInterface?: boolean; isJSXElement?: boolean } = {}, ...args: string[] ) { return args.reduce((prev, curr, i) => { return prev.replace(new RegExp(`\\$${i + 1}`, "g"), curr) - }, KindText[kind === "function" && insideClassOrInterface ? "method" : kind]) + }, KindText[kind === "function" && insideClassOrInterface ? "method" : isJSXElement ? (kind === "function" ? "jsx_component" : kind) : kind]) } export function getPrimitiveKindText(kind: PrimitiveKind) { @@ -80,6 +87,7 @@ export function localizePurpose(purpose: TypePurpose): string { type_parameter_list: "type parameters", type_argument_list: "type arguments", index_parameter_type: "parameter", + jsx_properties: "props", } return nameByPurpose[purpose] diff --git a/packages/api/src/localizedTree.ts b/packages/api/src/localizedTree.ts index 3b2cadf..2d01689 100644 --- a/packages/api/src/localizedTree.ts +++ b/packages/api/src/localizedTree.ts @@ -176,16 +176,17 @@ function getChildren( } case "function": { - const { signatures } = info + const { signatures, isJSXElement } = info if (signatures.length === 1) { return getLocalizedSignatureChildren( signatures[0], + isJSXElement, typeArguments ) } else { return signatures.map((sig) => - getLocalizedSignature(sig, typeParameters) + getLocalizedSignature(sig, isJSXElement, typeParameters) ) } } @@ -401,21 +402,27 @@ function getChildren( function getLocalizedSignature( signature: SignatureInfo, + isInsideJSXElement: boolean | undefined, typeArguments?: TypeInfo[] ) { const symbol = wrapSafe(localizeSymbol)(signature.symbolMeta) return createChild({ - kindText: "signature", + kindText: !isInsideJSXElement ? "signature" : "definition", kind: "signature", symbol, locations: symbol?.locations, - children: getLocalizedSignatureChildren(signature, typeArguments), + children: getLocalizedSignatureChildren( + signature, + isInsideJSXElement, + typeArguments + ), }) } function getLocalizedSignatureChildren( signature: SignatureInfo, + isInsideJSXElement: boolean | undefined, typeArguments?: TypeInfo[] ) { return [ @@ -423,7 +430,14 @@ function getChildren( signature.typeParameters, typeArguments ), - ...signature.parameters.map(localize), + ...signature.parameters.map((p, i) => + localizeOpts( + p, + i === 0 && isInsideJSXElement + ? { purpose: "jsx_properties" } + : undefined + ) + ), ...(signature.returnType ? [localizeOpts(signature.returnType, { purpose: "return" })] : []), @@ -486,7 +500,10 @@ function getKind(info: ResolvedTypeInfo): string { const kindText = (kind: LocalizableKind, ...args: string[]) => getKindText( kind, - { insideClassOrInterface: info.symbolMeta?.insideClassOrInterface }, + { + insideClassOrInterface: info.symbolMeta?.insideClassOrInterface, + isJSXElement: info.kind === "function" && info.isJSXElement, + }, ...args ) diff --git a/packages/api/src/objectUtil.ts b/packages/api/src/objectUtil.ts index e4429e4..89b8577 100644 --- a/packages/api/src/objectUtil.ts +++ b/packages/api/src/objectUtil.ts @@ -56,3 +56,14 @@ export function removeDuplicates(arr: T[]) { return val }) } + +/** + * @internal + */ +export function cartesianEqual( + arr1: T[], + arr2: T[], + eq?: (t: T, k: T) => boolean +) { + return arr1.some((x) => arr2.some((y) => eq?.(x, y) ?? x === y)) +} diff --git a/packages/api/src/tree.ts b/packages/api/src/tree.ts index afd441f..526dbcc 100644 --- a/packages/api/src/tree.ts +++ b/packages/api/src/tree.ts @@ -7,6 +7,7 @@ import { isNonEmpty, arrayContentsEqual, removeDuplicates, + cartesianEqual, } from "./objectUtil" import { DeclarationInfo, @@ -373,6 +374,17 @@ function _generateTypeTree( }), } } else if (signatures.length > 0) { + const isJSXElement = !!( + node && + cartesianEqual( + [node.kind, node.parent?.kind], + [ + ts.SyntaxKind.JsxElement, + ts.SyntaxKind.JsxSelfClosingElement, + ] + ) + ) + return { kind: "function", signatures: signatures.map((s) => @@ -382,6 +394,7 @@ function _generateTypeTree( typeParameters: s.typeParameters, }) ), + ...(isJSXElement && { isJSXElement }), } } else { return { diff --git a/packages/api/src/types.ts b/packages/api/src/types.ts index abe62ce..96636d4 100644 --- a/packages/api/src/types.ts +++ b/packages/api/src/types.ts @@ -114,7 +114,7 @@ export type TypeInfoNoId = { classSymbol?: SymbolInfo indexInfos?: IndexInfo[] } - | { kind: "function"; signatures: SignatureInfo[] } + | { kind: "function"; signatures: SignatureInfo[]; isJSXElement?: boolean } | { kind: "array"; type: TypeInfo } | { kind: "tuple"; types: TypeInfo[]; names?: string[] } | { @@ -193,6 +193,7 @@ export type TypePurpose = | "type_parameter_list" | "type_argument_list" | "parameter_value" + | "jsx_properties" export type PrimitiveKind = TypeInfoKind<"primitive">["primitive"] export type LocalizableKind = Exclude @@ -302,6 +303,7 @@ export type LocalizeOpts = { typeArguments?: TypeInfo[] typeArgument?: TypeInfo includeIds?: boolean + isInsideJSXElement?: boolean } /** diff --git a/packages/api/src/util.ts b/packages/api/src/util.ts index 65cab95..25229af 100644 --- a/packages/api/src/util.ts +++ b/packages/api/src/util.ts @@ -92,7 +92,7 @@ export function getNodeType(ctx: TypescriptContext, node: ts.Node) { )(getNodeSymbol(ctx, node)) if (symbolType && isValidType(symbolType)) return symbolType - if (ts.isTypeNode(node) || ts.isTypeNode(node.parent)) { + if (ts.isTypeNode(node) || (node.parent && ts.isTypeNode(node.parent))) { const typeNode = ts.isTypeNode(node) ? node : ts.isTypeNode(node.parent) @@ -701,16 +701,18 @@ export function getSignatureTypeArguments( export function getDescendantAtPosition( ctx: SourceFileTypescriptContext, + sourceFile: ts.SourceFile, position: number ) { - return getDescendantAtRange(ctx, [position, position]) + return getDescendantAtRange(ctx, sourceFile, [position, position]) } /** * https://github.com/dsherret/ts-ast-viewer/blob/b4be8f2234a1c3c099296bf5d0ad6cc14107367c/site/src/compiler/getDescendantAtRange.ts */ export function getDescendantAtRange( - { sourceFile, ts }: SourceFileTypescriptContext, + { ts }: TypescriptContext, + sourceFile: ts.SourceFile, range: [number, number] ) { let bestMatch: { node: ts.Node; start: number } = { diff --git a/packages/typescript-explorer-vscode/src/view/typeTreeView.ts b/packages/typescript-explorer-vscode/src/view/typeTreeView.ts index c007a99..d1c95fb 100644 --- a/packages/typescript-explorer-vscode/src/view/typeTreeView.ts +++ b/packages/typescript-explorer-vscode/src/view/typeTreeView.ts @@ -148,15 +148,10 @@ export class TypeTreeItem extends vscode.TreeItem { private provider: TypeTreeProvider, protected parent?: TypeTreeItem ) { - const { label, description, contextValue, icon } = getMeta(typeInfo) - const depth = (parent?.depth ?? 0) + 1 - const collapsibleState = - (typeInfo.children?.length ?? 0) === 0 - ? NoChildren - : depth === 1 - ? Expanded - : Collapsed + + const { label, description, contextValue, icon, collapsibleState } = + getMeta(typeInfo, depth) super(label, collapsibleState) @@ -201,19 +196,35 @@ type TypeTreeItemMeta = { description?: string contextValue?: TypeTreeItemContextValue icon?: vscode.ThemeIcon + collapsibleState: vscode.TreeItemCollapsibleState } -function getMeta(info: LocalizedTypeInfo): TypeTreeItemMeta { +function getMeta(info: LocalizedTypeInfo, depth: number): TypeTreeItemMeta { let nameOverridden = false const label = getLabel() const description = getDescription() + const collapsibleState = getCollapsibleState() + return { label, description, contextValue: getContextValue(), icon: getIcon(), + collapsibleState, + } + + function getCollapsibleState() { + if ((info.children?.length ?? 0) === 0) { + return NoChildren + } + + if (info.purpose === "jsx_properties") { + return Expanded + } + + return depth === 1 ? Expanded : Collapsed } function getLabel() { @@ -255,7 +266,10 @@ function getMeta(info: LocalizedTypeInfo): TypeTreeItemMeta { const baseDescription = decorate(info.kindText) const aliasDescriptionBase = - info.alias ?? (nameOverridden && info.symbol?.name) + info.alias ?? + (nameOverridden && + info.purpose !== "jsx_properties" && + info.symbol?.name) const aliasDescription = aliasDescriptionBase && decorate(aliasDescriptionBase) diff --git a/packages/typescript-plugin/src/index.ts b/packages/typescript-plugin/src/index.ts index d8526a0..e9c33ab 100644 --- a/packages/typescript-plugin/src/index.ts +++ b/packages/typescript-plugin/src/index.ts @@ -53,7 +53,7 @@ function init(modules: { ts: modules.typescript, } - const node = getDescendantAtPosition(ctx, position) + const node = getDescendantAtPosition(ctx, ctx.sourceFile, position) if (!node || node === sourceFile) { // Avoid giving quickInfo for the sourceFile as a whole. diff --git a/tests/baselines/reference/jsxFunctionComponent.localized.tree b/tests/baselines/reference/jsxFunctionComponent.localized.tree new file mode 100644 index 0000000..cab1867 --- /dev/null +++ b/tests/baselines/reference/jsxFunctionComponent.localized.tree @@ -0,0 +1,2531 @@ +=== jsxFunctionComponent.tsx === + +function Comp(props: { abc: string, ad?: number }) { + return <> +} +> function --- { + "kindText": "function", + "kind": "function", + "symbol": { + "name": "Comp", + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 9 + }, + "end": { + "line": 0, + "character": 13 + } + } + } + ] + }, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 9 + }, + "end": { + "line": 0, + "character": 13 + } + } + } + ], + "children": [ + { + "kindText": "object", + "kind": "object", + "symbol": { + "name": "props", + "isArgument": true, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 14 + }, + "end": { + "line": 0, + "character": 19 + } + } + } + ] + }, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 14 + }, + "end": { + "line": 0, + "character": 19 + } + } + } + ], + "children": [ + { + "kindText": "string", + "kind": "primitive", + "primitiveKind": "string", + "symbol": { + "name": "abc", + "property": true, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 23 + }, + "end": { + "line": 0, + "character": 26 + } + } + } + ] + }, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 23 + }, + "end": { + "line": 0, + "character": 26 + } + } + } + ], + "children": [], + "_id": "2" + }, + { + "kindText": "number", + "kind": "primitive", + "primitiveKind": "number", + "symbol": { + "name": "ad", + "property": true, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 36 + }, + "end": { + "line": 0, + "character": 38 + } + } + } + ] + }, + "optional": true, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 36 + }, + "end": { + "line": 0, + "character": 38 + } + } + } + ], + "children": [], + "_id": "3" + } + ], + "_id": "1" + }, + { + "kindText": "interface", + "kind": "interface", + "symbol": { + "name": "Element", + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 3121, + "character": 18 + }, + "end": { + "line": 3121, + "character": 25 + } + } + } + ] + }, + "purpose": "return", + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 3121, + "character": 18 + }, + "end": { + "line": 3121, + "character": 25 + } + } + } + ], + "children": [ + { + "kindText": "object", + "kind": "object", + "symbol": { + "name": "ReactElement", + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 14 + }, + "end": { + "line": 139, + "character": 26 + } + } + } + ] + }, + "purpose": "class_base_type", + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 14 + }, + "end": { + "line": 139, + "character": 26 + } + } + } + ], + "children": [ + { + "purpose": "type_parameter_list", + "children": [ + { + "kindText": "type parameter", + "kind": "type_parameter", + "symbol": { + "name": "P", + "insideClassOrInterface": true, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 27 + }, + "end": { + "line": 139, + "character": 28 + } + } + } + ] + }, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 27 + }, + "end": { + "line": 139, + "character": 28 + } + } + } + ], + "children": [ + { + "kindText": "any", + "kind": "primitive", + "primitiveKind": "any", + "purpose": "parameter_value", + "children": [], + "_id": "7" + }, + { + "reference": "7" + } + ], + "_id": "6" + }, + { + "kindText": "type parameter", + "kind": "type_parameter", + "symbol": { + "name": "T", + "insideClassOrInterface": true, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 36 + }, + "end": { + "line": 139, + "character": 37 + } + } + } + ] + }, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 36 + }, + "end": { + "line": 139, + "character": 37 + } + } + } + ], + "children": [ + { + "reference": "7" + }, + { + "kindText": "union", + "kind": "union", + "purpose": "parameter_default", + "children": [ + { + "kindText": "string", + "kind": "primitive", + "primitiveKind": "string", + "children": [], + "_id": "10" + }, + { + "kindText": "function", + "kind": "function", + "symbol": { + "name": "__type", + "anonymous": true, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 77, + "character": 11 + }, + "end": { + "line": 77, + "character": 54 + } + } + } + ] + }, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 77, + "character": 11 + }, + "end": { + "line": 77, + "character": 54 + } + } + } + ], + "children": [ + { + "kindText": "...", + "kind": "max_depth", + "children": [], + "_id": "12" + }, + { + "reference": "12" + } + ], + "_id": "11" + }, + { + "kindText": "function", + "kind": "function", + "symbol": { + "name": "__type", + "anonymous": true, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 78, + "character": 11 + }, + "end": { + "line": 78, + "character": 48 + } + } + } + ] + }, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 78, + "character": 11 + }, + "end": { + "line": 78, + "character": 48 + } + } + } + ], + "children": [ + { + "reference": "12" + }, + { + "reference": "12" + } + ], + "_id": "13" + } + ], + "_id": "9" + }, + { + "reference": "9" + } + ], + "_id": "8" + } + ] + }, + { + "reference": "7" + }, + { + "reference": "7" + }, + { + "kindText": "union", + "kind": "union", + "alias": "Key", + "symbol": { + "name": "key", + "insideClassOrInterface": true, + "property": true, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 142, + "character": 8 + }, + "end": { + "line": 142, + "character": 11 + } + } + } + ] + }, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 123, + "character": 9 + }, + "end": { + "line": 123, + "character": 12 + } + } + } + ], + "children": [ + { + "reference": "10" + }, + { + "kindText": "number", + "kind": "primitive", + "primitiveKind": "number", + "children": [], + "_id": "15" + } + ], + "_id": "14" + } + ], + "_id": "5" + }, + { + "reference": "7" + }, + { + "reference": "7" + }, + { + "kindText": "union", + "kind": "union", + "alias": "Key", + "symbol": { + "name": "key", + "insideClassOrInterface": true, + "property": true, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 142, + "character": 8 + }, + "end": { + "line": 142, + "character": 11 + } + } + } + ] + }, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 123, + "character": 9 + }, + "end": { + "line": 123, + "character": 12 + } + } + } + ], + "children": [ + { + "reference": "10" + }, + { + "reference": "15" + } + ], + "_id": "16" + } + ], + "_id": "4" + } + ], + "_id": "0" +} +> Comp --- { + "kindText": "function", + "kind": "function", + "symbol": { + "name": "Comp", + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 9 + }, + "end": { + "line": 0, + "character": 13 + } + } + } + ] + }, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 9 + }, + "end": { + "line": 0, + "character": 13 + } + } + } + ], + "children": [ + { + "kindText": "object", + "kind": "object", + "symbol": { + "name": "props", + "isArgument": true, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 14 + }, + "end": { + "line": 0, + "character": 19 + } + } + } + ] + }, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 14 + }, + "end": { + "line": 0, + "character": 19 + } + } + } + ], + "children": [ + { + "kindText": "string", + "kind": "primitive", + "primitiveKind": "string", + "symbol": { + "name": "abc", + "property": true, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 23 + }, + "end": { + "line": 0, + "character": 26 + } + } + } + ] + }, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 23 + }, + "end": { + "line": 0, + "character": 26 + } + } + } + ], + "children": [], + "_id": "2" + }, + { + "kindText": "number", + "kind": "primitive", + "primitiveKind": "number", + "symbol": { + "name": "ad", + "property": true, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 36 + }, + "end": { + "line": 0, + "character": 38 + } + } + } + ] + }, + "optional": true, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 36 + }, + "end": { + "line": 0, + "character": 38 + } + } + } + ], + "children": [], + "_id": "3" + } + ], + "_id": "1" + }, + { + "kindText": "interface", + "kind": "interface", + "symbol": { + "name": "Element", + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 3121, + "character": 18 + }, + "end": { + "line": 3121, + "character": 25 + } + } + } + ] + }, + "purpose": "return", + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 3121, + "character": 18 + }, + "end": { + "line": 3121, + "character": 25 + } + } + } + ], + "children": [ + { + "kindText": "object", + "kind": "object", + "symbol": { + "name": "ReactElement", + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 14 + }, + "end": { + "line": 139, + "character": 26 + } + } + } + ] + }, + "purpose": "class_base_type", + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 14 + }, + "end": { + "line": 139, + "character": 26 + } + } + } + ], + "children": [ + { + "purpose": "type_parameter_list", + "children": [ + { + "kindText": "type parameter", + "kind": "type_parameter", + "symbol": { + "name": "P", + "insideClassOrInterface": true, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 27 + }, + "end": { + "line": 139, + "character": 28 + } + } + } + ] + }, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 27 + }, + "end": { + "line": 139, + "character": 28 + } + } + } + ], + "children": [ + { + "kindText": "any", + "kind": "primitive", + "primitiveKind": "any", + "purpose": "parameter_value", + "children": [], + "_id": "7" + }, + { + "reference": "7" + } + ], + "_id": "6" + }, + { + "kindText": "type parameter", + "kind": "type_parameter", + "symbol": { + "name": "T", + "insideClassOrInterface": true, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 36 + }, + "end": { + "line": 139, + "character": 37 + } + } + } + ] + }, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 36 + }, + "end": { + "line": 139, + "character": 37 + } + } + } + ], + "children": [ + { + "reference": "7" + }, + { + "kindText": "union", + "kind": "union", + "purpose": "parameter_default", + "children": [ + { + "kindText": "string", + "kind": "primitive", + "primitiveKind": "string", + "children": [], + "_id": "10" + }, + { + "kindText": "function", + "kind": "function", + "symbol": { + "name": "__type", + "anonymous": true, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 77, + "character": 11 + }, + "end": { + "line": 77, + "character": 54 + } + } + } + ] + }, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 77, + "character": 11 + }, + "end": { + "line": 77, + "character": 54 + } + } + } + ], + "children": [ + { + "kindText": "...", + "kind": "max_depth", + "children": [], + "_id": "12" + }, + { + "reference": "12" + } + ], + "_id": "11" + }, + { + "kindText": "function", + "kind": "function", + "symbol": { + "name": "__type", + "anonymous": true, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 78, + "character": 11 + }, + "end": { + "line": 78, + "character": 48 + } + } + } + ] + }, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 78, + "character": 11 + }, + "end": { + "line": 78, + "character": 48 + } + } + } + ], + "children": [ + { + "reference": "12" + }, + { + "reference": "12" + } + ], + "_id": "13" + } + ], + "_id": "9" + }, + { + "reference": "9" + } + ], + "_id": "8" + } + ] + }, + { + "reference": "7" + }, + { + "reference": "7" + }, + { + "kindText": "union", + "kind": "union", + "alias": "Key", + "symbol": { + "name": "key", + "insideClassOrInterface": true, + "property": true, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 142, + "character": 8 + }, + "end": { + "line": 142, + "character": 11 + } + } + } + ] + }, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 123, + "character": 9 + }, + "end": { + "line": 123, + "character": 12 + } + } + } + ], + "children": [ + { + "reference": "10" + }, + { + "kindText": "number", + "kind": "primitive", + "primitiveKind": "number", + "children": [], + "_id": "15" + } + ], + "_id": "14" + } + ], + "_id": "5" + }, + { + "reference": "7" + }, + { + "reference": "7" + }, + { + "kindText": "union", + "kind": "union", + "alias": "Key", + "symbol": { + "name": "key", + "insideClassOrInterface": true, + "property": true, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 142, + "character": 8 + }, + "end": { + "line": 142, + "character": 11 + } + } + } + ] + }, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 123, + "character": 9 + }, + "end": { + "line": 123, + "character": 12 + } + } + } + ], + "children": [ + { + "reference": "10" + }, + { + "reference": "15" + } + ], + "_id": "16" + } + ], + "_id": "4" + } + ], + "_id": "0" +} +> props: { abc: string, ad?: number } +> props: { abc: string, ad?: number } +> props --- { + "kindText": "object", + "kind": "object", + "symbol": { + "name": "props", + "isArgument": true, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 14 + }, + "end": { + "line": 0, + "character": 19 + } + } + } + ] + }, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 14 + }, + "end": { + "line": 0, + "character": 19 + } + } + } + ], + "children": [ + { + "kindText": "string", + "kind": "primitive", + "primitiveKind": "string", + "symbol": { + "name": "abc", + "property": true, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 23 + }, + "end": { + "line": 0, + "character": 26 + } + } + } + ] + }, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 23 + }, + "end": { + "line": 0, + "character": 26 + } + } + } + ], + "children": [], + "_id": "1" + }, + { + "kindText": "number", + "kind": "primitive", + "primitiveKind": "number", + "symbol": { + "name": "ad", + "property": true, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 36 + }, + "end": { + "line": 0, + "character": 38 + } + } + } + ] + }, + "optional": true, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 36 + }, + "end": { + "line": 0, + "character": 38 + } + } + } + ], + "children": [], + "_id": "2" + } + ], + "_id": "0" +} +> { abc: string, ad?: number } +> abc: string, ad?: number +> abc: string, +> abc --- { + "kindText": "string", + "kind": "primitive", + "primitiveKind": "string", + "symbol": { + "name": "abc", + "property": true, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 23 + }, + "end": { + "line": 0, + "character": 26 + } + } + } + ] + }, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 23 + }, + "end": { + "line": 0, + "character": 26 + } + } + } + ], + "children": [], + "_id": "0" +} +> ad?: number +> ad --- { + "kindText": "number", + "kind": "primitive", + "primitiveKind": "number", + "symbol": { + "name": "ad", + "property": true, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 36 + }, + "end": { + "line": 0, + "character": 38 + } + } + } + ] + }, + "optional": true, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 36 + }, + "end": { + "line": 0, + "character": 38 + } + } + } + ], + "children": [], + "_id": "0" +} + +const a = +> const a = +> a = +> a = +> a --- { + "kindText": "interface", + "kind": "interface", + "alias": "Element", + "symbol": { + "name": "a", + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 4, + "character": 6 + }, + "end": { + "line": 4, + "character": 7 + } + } + } + ] + }, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 3121, + "character": 18 + }, + "end": { + "line": 3121, + "character": 25 + } + } + } + ], + "children": [ + { + "kindText": "object", + "kind": "object", + "symbol": { + "name": "ReactElement", + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 14 + }, + "end": { + "line": 139, + "character": 26 + } + } + } + ] + }, + "purpose": "class_base_type", + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 14 + }, + "end": { + "line": 139, + "character": 26 + } + } + } + ], + "children": [ + { + "purpose": "type_parameter_list", + "children": [ + { + "kindText": "type parameter", + "kind": "type_parameter", + "symbol": { + "name": "P", + "insideClassOrInterface": true, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 27 + }, + "end": { + "line": 139, + "character": 28 + } + } + } + ] + }, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 27 + }, + "end": { + "line": 139, + "character": 28 + } + } + } + ], + "children": [ + { + "kindText": "any", + "kind": "primitive", + "primitiveKind": "any", + "purpose": "parameter_value", + "children": [], + "_id": "3" + }, + { + "reference": "3" + } + ], + "_id": "2" + }, + { + "kindText": "type parameter", + "kind": "type_parameter", + "symbol": { + "name": "T", + "insideClassOrInterface": true, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 36 + }, + "end": { + "line": 139, + "character": 37 + } + } + } + ] + }, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 36 + }, + "end": { + "line": 139, + "character": 37 + } + } + } + ], + "children": [ + { + "reference": "3" + }, + { + "kindText": "union", + "kind": "union", + "purpose": "parameter_default", + "children": [ + { + "kindText": "string", + "kind": "primitive", + "primitiveKind": "string", + "children": [], + "_id": "6" + }, + { + "kindText": "function", + "kind": "function", + "symbol": { + "name": "__type", + "anonymous": true, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 77, + "character": 11 + }, + "end": { + "line": 77, + "character": 54 + } + } + } + ] + }, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 77, + "character": 11 + }, + "end": { + "line": 77, + "character": 54 + } + } + } + ], + "children": [ + { + "reference": "3" + }, + { + "reference": "1" + } + ], + "_id": "7" + }, + { + "kindText": "function", + "kind": "function", + "symbol": { + "name": "__type", + "anonymous": true, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 78, + "character": 11 + }, + "end": { + "line": 78, + "character": 48 + } + } + } + ] + }, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 78, + "character": 11 + }, + "end": { + "line": 78, + "character": 48 + } + } + } + ], + "children": [ + { + "reference": "3" + }, + { + "kindText": "object", + "kind": "object", + "symbol": { + "name": "Component", + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 429, + "character": 14 + }, + "end": { + "line": 429, + "character": 23 + } + } + }, + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 430, + "character": 10 + }, + "end": { + "line": 430, + "character": 19 + } + } + } + ] + }, + "purpose": "return", + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 429, + "character": 14 + }, + "end": { + "line": 429, + "character": 23 + } + } + }, + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 430, + "character": 10 + }, + "end": { + "line": 430, + "character": 19 + } + } + } + ], + "children": [ + { + "kindText": "...", + "kind": "max_depth", + "purpose": "object_class", + "children": [ + { + "purpose": "type_argument_list", + "children": [ + { + "reference": "10" + } + ] + } + ], + "_id": "10" + }, + { + "reference": "10" + } + ], + "_id": "9" + } + ], + "_id": "8" + } + ], + "_id": "5" + }, + { + "reference": "5" + } + ], + "_id": "4" + } + ] + }, + { + "reference": "3" + }, + { + "reference": "3" + }, + { + "kindText": "union", + "kind": "union", + "alias": "Key", + "symbol": { + "name": "key", + "insideClassOrInterface": true, + "property": true, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 142, + "character": 8 + }, + "end": { + "line": 142, + "character": 11 + } + } + } + ] + }, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 123, + "character": 9 + }, + "end": { + "line": 123, + "character": 12 + } + } + } + ], + "children": [ + { + "reference": "6" + }, + { + "kindText": "number", + "kind": "primitive", + "primitiveKind": "number", + "children": [], + "_id": "12" + } + ], + "_id": "11" + } + ], + "_id": "1" + }, + { + "reference": "3" + }, + { + "reference": "3" + }, + { + "kindText": "union", + "kind": "union", + "alias": "Key", + "symbol": { + "name": "key", + "insideClassOrInterface": true, + "property": true, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 142, + "character": 8 + }, + "end": { + "line": 142, + "character": 11 + } + } + } + ] + }, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 123, + "character": 9 + }, + "end": { + "line": 123, + "character": 12 + } + } + } + ], + "children": [ + { + "reference": "6" + }, + { + "reference": "12" + } + ], + "_id": "13" + } + ], + "_id": "0" +} +> +> Comp --- { + "kindText": "component", + "kind": "function", + "symbol": { + "name": "Comp", + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 9 + }, + "end": { + "line": 0, + "character": 13 + } + } + } + ] + }, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 9 + }, + "end": { + "line": 0, + "character": 13 + } + } + } + ], + "children": [ + { + "kindText": "object", + "kind": "object", + "symbol": { + "name": "props", + "isArgument": true, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 14 + }, + "end": { + "line": 0, + "character": 19 + } + } + } + ] + }, + "purpose": "jsx_properties", + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 14 + }, + "end": { + "line": 0, + "character": 19 + } + } + } + ], + "children": [ + { + "kindText": "string", + "kind": "primitive", + "primitiveKind": "string", + "symbol": { + "name": "abc", + "property": true, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 23 + }, + "end": { + "line": 0, + "character": 26 + } + } + } + ] + }, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 23 + }, + "end": { + "line": 0, + "character": 26 + } + } + } + ], + "children": [], + "_id": "2" + }, + { + "kindText": "number", + "kind": "primitive", + "primitiveKind": "number", + "symbol": { + "name": "ad", + "property": true, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 36 + }, + "end": { + "line": 0, + "character": 38 + } + } + } + ] + }, + "optional": true, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 36 + }, + "end": { + "line": 0, + "character": 38 + } + } + } + ], + "children": [], + "_id": "3" + } + ], + "_id": "1" + }, + { + "kindText": "interface", + "kind": "interface", + "symbol": { + "name": "Element", + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 3121, + "character": 18 + }, + "end": { + "line": 3121, + "character": 25 + } + } + } + ] + }, + "purpose": "return", + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 3121, + "character": 18 + }, + "end": { + "line": 3121, + "character": 25 + } + } + } + ], + "children": [ + { + "kindText": "object", + "kind": "object", + "symbol": { + "name": "ReactElement", + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 14 + }, + "end": { + "line": 139, + "character": 26 + } + } + } + ] + }, + "purpose": "class_base_type", + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 14 + }, + "end": { + "line": 139, + "character": 26 + } + } + } + ], + "children": [ + { + "purpose": "type_parameter_list", + "children": [ + { + "kindText": "type parameter", + "kind": "type_parameter", + "symbol": { + "name": "P", + "insideClassOrInterface": true, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 27 + }, + "end": { + "line": 139, + "character": 28 + } + } + } + ] + }, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 27 + }, + "end": { + "line": 139, + "character": 28 + } + } + } + ], + "children": [ + { + "kindText": "any", + "kind": "primitive", + "primitiveKind": "any", + "purpose": "parameter_value", + "children": [], + "_id": "7" + }, + { + "reference": "7" + } + ], + "_id": "6" + }, + { + "kindText": "type parameter", + "kind": "type_parameter", + "symbol": { + "name": "T", + "insideClassOrInterface": true, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 36 + }, + "end": { + "line": 139, + "character": 37 + } + } + } + ] + }, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 36 + }, + "end": { + "line": 139, + "character": 37 + } + } + } + ], + "children": [ + { + "reference": "7" + }, + { + "kindText": "union", + "kind": "union", + "purpose": "parameter_default", + "children": [ + { + "kindText": "string", + "kind": "primitive", + "primitiveKind": "string", + "children": [], + "_id": "10" + }, + { + "kindText": "function", + "kind": "function", + "symbol": { + "name": "__type", + "anonymous": true, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 77, + "character": 11 + }, + "end": { + "line": 77, + "character": 54 + } + } + } + ] + }, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 77, + "character": 11 + }, + "end": { + "line": 77, + "character": 54 + } + } + } + ], + "children": [ + { + "kindText": "...", + "kind": "max_depth", + "children": [], + "_id": "12" + }, + { + "reference": "12" + } + ], + "_id": "11" + }, + { + "kindText": "function", + "kind": "function", + "symbol": { + "name": "__type", + "anonymous": true, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 78, + "character": 11 + }, + "end": { + "line": 78, + "character": 48 + } + } + } + ] + }, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 78, + "character": 11 + }, + "end": { + "line": 78, + "character": 48 + } + } + } + ], + "children": [ + { + "reference": "12" + }, + { + "reference": "12" + } + ], + "_id": "13" + } + ], + "_id": "9" + }, + { + "reference": "9" + } + ], + "_id": "8" + } + ] + }, + { + "reference": "7" + }, + { + "reference": "7" + }, + { + "kindText": "union", + "kind": "union", + "alias": "Key", + "symbol": { + "name": "key", + "insideClassOrInterface": true, + "property": true, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 142, + "character": 8 + }, + "end": { + "line": 142, + "character": 11 + } + } + } + ] + }, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 123, + "character": 9 + }, + "end": { + "line": 123, + "character": 12 + } + } + } + ], + "children": [ + { + "reference": "10" + }, + { + "kindText": "number", + "kind": "primitive", + "primitiveKind": "number", + "children": [], + "_id": "15" + } + ], + "_id": "14" + } + ], + "_id": "5" + }, + { + "reference": "7" + }, + { + "reference": "7" + }, + { + "kindText": "union", + "kind": "union", + "alias": "Key", + "symbol": { + "name": "key", + "insideClassOrInterface": true, + "property": true, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 142, + "character": 8 + }, + "end": { + "line": 142, + "character": 11 + } + } + } + ] + }, + "locations": [ + { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 123, + "character": 9 + }, + "end": { + "line": 123, + "character": 12 + } + } + } + ], + "children": [ + { + "reference": "10" + }, + { + "reference": "15" + } + ], + "_id": "16" + } + ], + "_id": "4" + } + ], + "_id": "0" +} +> abc="asc" ad={4} +> abc="asc" ad={4} +> abc="asc" +> abc --- { + "kindText": "string", + "kind": "primitive", + "primitiveKind": "string", + "symbol": { + "name": "abc", + "property": true, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 4, + "character": 16 + }, + "end": { + "line": 4, + "character": 19 + } + } + } + ] + }, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 4, + "character": 16 + }, + "end": { + "line": 4, + "character": 19 + } + } + } + ], + "children": [], + "_id": "0" +} +> ad={4} +> ad --- { + "kindText": "number", + "kind": "primitive", + "primitiveKind": "number", + "symbol": { + "name": "ad", + "property": true, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 4, + "character": 26 + }, + "end": { + "line": 4, + "character": 28 + } + } + } + ] + }, + "locations": [ + { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 4, + "character": 26 + }, + "end": { + "line": 4, + "character": 28 + } + } + } + ], + "children": [], + "_id": "0" +} \ No newline at end of file diff --git a/tests/baselines/reference/jsxFunctionComponent.tree b/tests/baselines/reference/jsxFunctionComponent.tree new file mode 100644 index 0000000..9921a00 --- /dev/null +++ b/tests/baselines/reference/jsxFunctionComponent.tree @@ -0,0 +1,2667 @@ +=== jsxFunctionComponent.tsx === + +function Comp(props: { abc: string, ad?: number }) { + return <> +} +> function --- { + "kind": "function", + "signatures": [ + { + "symbolMeta": { + "name": "Comp", + "flags": 16, + "declarations": [ + { + "location": { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 9 + }, + "end": { + "line": 0, + "character": 13 + } + } + } + } + ] + }, + "parameters": [ + { + "kind": "object", + "properties": [ + { + "kind": "primitive", + "primitive": "string", + "symbolMeta": { + "name": "abc", + "flags": 4, + "declarations": [ + { + "location": { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 23 + }, + "end": { + "line": 0, + "character": 26 + } + } + } + } + ] + }, + "id": "2" + }, + { + "kind": "primitive", + "primitive": "number", + "symbolMeta": { + "name": "ad", + "flags": 16777220, + "declarations": [ + { + "location": { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 36 + }, + "end": { + "line": 0, + "character": 38 + } + } + } + } + ] + }, + "id": "3" + } + ], + "indexInfos": [], + "symbolMeta": { + "name": "props", + "flags": 1, + "declarations": [ + { + "location": { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 14 + }, + "end": { + "line": 0, + "character": 19 + } + } + } + } + ] + }, + "id": "1" + } + ], + "returnType": { + "kind": "interface", + "properties": [ + { + "kind": "primitive", + "primitive": "any", + "symbolMeta": { + "name": "type", + "flags": 33554436, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 140, + "character": 8 + }, + "end": { + "line": 140, + "character": 12 + } + } + } + } + ] + }, + "id": "5" + }, + { + "kind": "reference", + "symbolMeta": { + "name": "props", + "flags": 33554436, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 141, + "character": 8 + }, + "end": { + "line": 141, + "character": 13 + } + } + } + } + ] + }, + "id": "5" + }, + { + "kind": "union", + "types": [ + { + "kind": "primitive", + "primitive": "string", + "id": "7" + }, + { + "kind": "primitive", + "primitive": "number", + "id": "8" + } + ], + "symbolMeta": { + "name": "key", + "flags": 33554436, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 142, + "character": 8 + }, + "end": { + "line": 142, + "character": 11 + } + } + } + } + ] + }, + "aliasSymbolMeta": { + "name": "Key", + "flags": 524288, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 123, + "character": 9 + }, + "end": { + "line": 123, + "character": 12 + } + } + } + } + ] + }, + "id": "6" + } + ], + "baseType": { + "kind": "object", + "properties": [ + { + "kind": "reference", + "symbolMeta": { + "name": "type", + "flags": 33554436, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 140, + "character": 8 + }, + "end": { + "line": 140, + "character": 12 + } + } + } + } + ] + }, + "id": "5" + }, + { + "kind": "reference", + "symbolMeta": { + "name": "props", + "flags": 33554436, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 141, + "character": 8 + }, + "end": { + "line": 141, + "character": 13 + } + } + } + } + ] + }, + "id": "5" + }, + { + "kind": "union", + "types": [ + { + "kind": "reference", + "id": "7" + }, + { + "kind": "reference", + "id": "8" + } + ], + "symbolMeta": { + "name": "key", + "flags": 4, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 142, + "character": 8 + }, + "end": { + "line": 142, + "character": 11 + } + } + } + } + ] + }, + "aliasSymbolMeta": { + "name": "Key", + "flags": 524288, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 123, + "character": 9 + }, + "end": { + "line": 123, + "character": 12 + } + } + } + } + ] + }, + "id": "19" + } + ], + "indexInfos": [], + "symbolMeta": { + "name": "ReactElement", + "flags": 64, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 14 + }, + "end": { + "line": 139, + "character": 26 + } + } + } + } + ] + }, + "typeParameters": [ + { + "kind": "type_parameter", + "defaultType": { + "kind": "reference", + "id": "5" + }, + "symbolMeta": { + "name": "P", + "flags": 262144, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 27 + }, + "end": { + "line": 139, + "character": 28 + } + } + } + } + ] + }, + "id": "10" + }, + { + "kind": "type_parameter", + "baseConstraint": { + "kind": "union", + "types": [ + { + "kind": "reference", + "id": "7" + }, + { + "kind": "function", + "signatures": [ + { + "symbolMeta": { + "name": "__type", + "flags": 2048, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 77, + "character": 11 + }, + "end": { + "line": 77, + "character": 54 + } + } + } + } + ] + }, + "parameters": [ + { + "kind": "max_depth", + "id": "18" + } + ], + "returnType": { + "kind": "max_depth", + "id": "18" + } + } + ], + "symbolMeta": { + "name": "__type", + "flags": 2048, + "anonymous": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 77, + "character": 11 + }, + "end": { + "line": 77, + "character": 54 + } + } + } + } + ] + }, + "id": "13" + }, + { + "kind": "function", + "signatures": [ + { + "symbolMeta": { + "name": "__type", + "flags": 2048, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 78, + "character": 11 + }, + "end": { + "line": 78, + "character": 48 + } + } + } + } + ] + }, + "parameters": [ + { + "kind": "max_depth", + "id": "18" + } + ], + "returnType": { + "kind": "max_depth", + "id": "18" + } + } + ], + "symbolMeta": { + "name": "__type", + "flags": 2048, + "anonymous": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 78, + "character": 11 + }, + "end": { + "line": 78, + "character": 48 + } + } + } + } + ] + }, + "id": "16" + } + ], + "id": "12" + }, + "defaultType": { + "kind": "reference", + "id": "12" + }, + "symbolMeta": { + "name": "T", + "flags": 262144, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 36 + }, + "end": { + "line": 139, + "character": 37 + } + } + } + } + ] + }, + "id": "11" + } + ], + "typeArguments": [ + { + "kind": "reference", + "id": "5" + }, + { + "kind": "reference", + "id": "5" + } + ], + "id": "9" + }, + "implementsTypes": [], + "constructSignatures": [], + "symbolMeta": { + "name": "Element", + "flags": 64, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 3121, + "character": 18 + }, + "end": { + "line": 3121, + "character": 25 + } + } + } + } + ] + }, + "id": "4" + } + } + ], + "symbolMeta": { + "name": "Comp", + "flags": 16, + "declarations": [ + { + "location": { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 9 + }, + "end": { + "line": 0, + "character": 13 + } + } + } + } + ] + }, + "id": "0" +} +> Comp --- { + "kind": "function", + "signatures": [ + { + "symbolMeta": { + "name": "Comp", + "flags": 16, + "declarations": [ + { + "location": { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 9 + }, + "end": { + "line": 0, + "character": 13 + } + } + } + } + ] + }, + "parameters": [ + { + "kind": "object", + "properties": [ + { + "kind": "primitive", + "primitive": "string", + "symbolMeta": { + "name": "abc", + "flags": 4, + "declarations": [ + { + "location": { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 23 + }, + "end": { + "line": 0, + "character": 26 + } + } + } + } + ] + }, + "id": "2" + }, + { + "kind": "primitive", + "primitive": "number", + "symbolMeta": { + "name": "ad", + "flags": 16777220, + "declarations": [ + { + "location": { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 36 + }, + "end": { + "line": 0, + "character": 38 + } + } + } + } + ] + }, + "id": "3" + } + ], + "indexInfos": [], + "symbolMeta": { + "name": "props", + "flags": 1, + "declarations": [ + { + "location": { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 14 + }, + "end": { + "line": 0, + "character": 19 + } + } + } + } + ] + }, + "id": "1" + } + ], + "returnType": { + "kind": "interface", + "properties": [ + { + "kind": "primitive", + "primitive": "any", + "symbolMeta": { + "name": "type", + "flags": 33554436, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 140, + "character": 8 + }, + "end": { + "line": 140, + "character": 12 + } + } + } + } + ] + }, + "id": "5" + }, + { + "kind": "reference", + "symbolMeta": { + "name": "props", + "flags": 33554436, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 141, + "character": 8 + }, + "end": { + "line": 141, + "character": 13 + } + } + } + } + ] + }, + "id": "5" + }, + { + "kind": "union", + "types": [ + { + "kind": "primitive", + "primitive": "string", + "id": "7" + }, + { + "kind": "primitive", + "primitive": "number", + "id": "8" + } + ], + "symbolMeta": { + "name": "key", + "flags": 33554436, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 142, + "character": 8 + }, + "end": { + "line": 142, + "character": 11 + } + } + } + } + ] + }, + "aliasSymbolMeta": { + "name": "Key", + "flags": 524288, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 123, + "character": 9 + }, + "end": { + "line": 123, + "character": 12 + } + } + } + } + ] + }, + "id": "6" + } + ], + "baseType": { + "kind": "object", + "properties": [ + { + "kind": "reference", + "symbolMeta": { + "name": "type", + "flags": 33554436, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 140, + "character": 8 + }, + "end": { + "line": 140, + "character": 12 + } + } + } + } + ] + }, + "id": "5" + }, + { + "kind": "reference", + "symbolMeta": { + "name": "props", + "flags": 33554436, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 141, + "character": 8 + }, + "end": { + "line": 141, + "character": 13 + } + } + } + } + ] + }, + "id": "5" + }, + { + "kind": "union", + "types": [ + { + "kind": "reference", + "id": "7" + }, + { + "kind": "reference", + "id": "8" + } + ], + "symbolMeta": { + "name": "key", + "flags": 4, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 142, + "character": 8 + }, + "end": { + "line": 142, + "character": 11 + } + } + } + } + ] + }, + "aliasSymbolMeta": { + "name": "Key", + "flags": 524288, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 123, + "character": 9 + }, + "end": { + "line": 123, + "character": 12 + } + } + } + } + ] + }, + "id": "19" + } + ], + "indexInfos": [], + "symbolMeta": { + "name": "ReactElement", + "flags": 64, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 14 + }, + "end": { + "line": 139, + "character": 26 + } + } + } + } + ] + }, + "typeParameters": [ + { + "kind": "type_parameter", + "defaultType": { + "kind": "reference", + "id": "5" + }, + "symbolMeta": { + "name": "P", + "flags": 262144, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 27 + }, + "end": { + "line": 139, + "character": 28 + } + } + } + } + ] + }, + "id": "10" + }, + { + "kind": "type_parameter", + "baseConstraint": { + "kind": "union", + "types": [ + { + "kind": "reference", + "id": "7" + }, + { + "kind": "function", + "signatures": [ + { + "symbolMeta": { + "name": "__type", + "flags": 2048, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 77, + "character": 11 + }, + "end": { + "line": 77, + "character": 54 + } + } + } + } + ] + }, + "parameters": [ + { + "kind": "max_depth", + "id": "18" + } + ], + "returnType": { + "kind": "max_depth", + "id": "18" + } + } + ], + "symbolMeta": { + "name": "__type", + "flags": 2048, + "anonymous": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 77, + "character": 11 + }, + "end": { + "line": 77, + "character": 54 + } + } + } + } + ] + }, + "id": "13" + }, + { + "kind": "function", + "signatures": [ + { + "symbolMeta": { + "name": "__type", + "flags": 2048, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 78, + "character": 11 + }, + "end": { + "line": 78, + "character": 48 + } + } + } + } + ] + }, + "parameters": [ + { + "kind": "max_depth", + "id": "18" + } + ], + "returnType": { + "kind": "max_depth", + "id": "18" + } + } + ], + "symbolMeta": { + "name": "__type", + "flags": 2048, + "anonymous": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 78, + "character": 11 + }, + "end": { + "line": 78, + "character": 48 + } + } + } + } + ] + }, + "id": "16" + } + ], + "id": "12" + }, + "defaultType": { + "kind": "reference", + "id": "12" + }, + "symbolMeta": { + "name": "T", + "flags": 262144, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 36 + }, + "end": { + "line": 139, + "character": 37 + } + } + } + } + ] + }, + "id": "11" + } + ], + "typeArguments": [ + { + "kind": "reference", + "id": "5" + }, + { + "kind": "reference", + "id": "5" + } + ], + "id": "9" + }, + "implementsTypes": [], + "constructSignatures": [], + "symbolMeta": { + "name": "Element", + "flags": 64, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 3121, + "character": 18 + }, + "end": { + "line": 3121, + "character": 25 + } + } + } + } + ] + }, + "id": "4" + } + } + ], + "symbolMeta": { + "name": "Comp", + "flags": 16, + "declarations": [ + { + "location": { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 9 + }, + "end": { + "line": 0, + "character": 13 + } + } + } + } + ] + }, + "id": "0" +} +> props: { abc: string, ad?: number } +> props: { abc: string, ad?: number } +> props --- { + "kind": "object", + "properties": [ + { + "kind": "primitive", + "primitive": "string", + "symbolMeta": { + "name": "abc", + "flags": 4, + "declarations": [ + { + "location": { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 23 + }, + "end": { + "line": 0, + "character": 26 + } + } + } + } + ] + }, + "id": "1" + }, + { + "kind": "primitive", + "primitive": "number", + "symbolMeta": { + "name": "ad", + "flags": 16777220, + "declarations": [ + { + "location": { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 36 + }, + "end": { + "line": 0, + "character": 38 + } + } + } + } + ] + }, + "id": "2" + } + ], + "indexInfos": [], + "symbolMeta": { + "name": "props", + "flags": 1, + "declarations": [ + { + "location": { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 14 + }, + "end": { + "line": 0, + "character": 19 + } + } + } + } + ] + }, + "id": "0" +} +> { abc: string, ad?: number } +> abc: string, ad?: number +> abc: string, +> abc --- { + "kind": "primitive", + "primitive": "string", + "symbolMeta": { + "name": "abc", + "flags": 4, + "declarations": [ + { + "location": { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 23 + }, + "end": { + "line": 0, + "character": 26 + } + } + } + } + ] + }, + "id": "0" +} +> ad?: number +> ad --- { + "kind": "primitive", + "primitive": "number", + "symbolMeta": { + "name": "ad", + "flags": 16777220, + "declarations": [ + { + "location": { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 36 + }, + "end": { + "line": 0, + "character": 38 + } + } + } + } + ] + }, + "id": "0" +} + +const a = +> const a = +> a = +> a = +> a --- { + "kind": "interface", + "properties": [ + { + "kind": "primitive", + "primitive": "any", + "symbolMeta": { + "name": "type", + "flags": 33554436, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 140, + "character": 8 + }, + "end": { + "line": 140, + "character": 12 + } + } + } + } + ] + }, + "id": "1" + }, + { + "kind": "reference", + "symbolMeta": { + "name": "props", + "flags": 33554436, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 141, + "character": 8 + }, + "end": { + "line": 141, + "character": 13 + } + } + } + } + ] + }, + "id": "1" + }, + { + "kind": "union", + "types": [ + { + "kind": "primitive", + "primitive": "string", + "id": "3" + }, + { + "kind": "primitive", + "primitive": "number", + "id": "4" + } + ], + "symbolMeta": { + "name": "key", + "flags": 33554436, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 142, + "character": 8 + }, + "end": { + "line": 142, + "character": 11 + } + } + } + } + ] + }, + "aliasSymbolMeta": { + "name": "Key", + "flags": 524288, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 123, + "character": 9 + }, + "end": { + "line": 123, + "character": 12 + } + } + } + } + ] + }, + "id": "2" + } + ], + "baseType": { + "kind": "object", + "properties": [ + { + "kind": "reference", + "symbolMeta": { + "name": "type", + "flags": 33554436, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 140, + "character": 8 + }, + "end": { + "line": 140, + "character": 12 + } + } + } + } + ] + }, + "id": "1" + }, + { + "kind": "reference", + "symbolMeta": { + "name": "props", + "flags": 33554436, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 141, + "character": 8 + }, + "end": { + "line": 141, + "character": 13 + } + } + } + } + ] + }, + "id": "1" + }, + { + "kind": "union", + "types": [ + { + "kind": "reference", + "id": "3" + }, + { + "kind": "reference", + "id": "4" + } + ], + "symbolMeta": { + "name": "key", + "flags": 4, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 142, + "character": 8 + }, + "end": { + "line": 142, + "character": 11 + } + } + } + } + ] + }, + "aliasSymbolMeta": { + "name": "Key", + "flags": 524288, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 123, + "character": 9 + }, + "end": { + "line": 123, + "character": 12 + } + } + } + } + ] + }, + "id": "15" + } + ], + "indexInfos": [], + "symbolMeta": { + "name": "ReactElement", + "flags": 64, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 14 + }, + "end": { + "line": 139, + "character": 26 + } + } + } + } + ] + }, + "typeParameters": [ + { + "kind": "type_parameter", + "defaultType": { + "kind": "reference", + "id": "1" + }, + "symbolMeta": { + "name": "P", + "flags": 262144, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 27 + }, + "end": { + "line": 139, + "character": 28 + } + } + } + } + ] + }, + "id": "6" + }, + { + "kind": "type_parameter", + "baseConstraint": { + "kind": "union", + "types": [ + { + "kind": "reference", + "id": "3" + }, + { + "kind": "function", + "signatures": [ + { + "symbolMeta": { + "name": "__type", + "flags": 2048, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 77, + "character": 11 + }, + "end": { + "line": 77, + "character": 54 + } + } + } + } + ] + }, + "parameters": [ + { + "kind": "reference", + "symbolMeta": { + "name": "props", + "flags": 33554433, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 77, + "character": 12 + }, + "end": { + "line": 77, + "character": 17 + } + } + } + } + ] + }, + "id": "1" + } + ], + "returnType": { + "kind": "reference", + "symbolMeta": { + "name": "ReactElement", + "flags": 64, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 14 + }, + "end": { + "line": 139, + "character": 26 + } + } + } + } + ] + }, + "id": "5" + } + } + ], + "symbolMeta": { + "name": "__type", + "flags": 2048, + "anonymous": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 77, + "character": 11 + }, + "end": { + "line": 77, + "character": 54 + } + } + } + } + ] + }, + "id": "9" + }, + { + "kind": "function", + "signatures": [ + { + "symbolMeta": { + "name": "__type", + "flags": 2048, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 78, + "character": 11 + }, + "end": { + "line": 78, + "character": 48 + } + } + } + } + ] + }, + "parameters": [ + { + "kind": "reference", + "symbolMeta": { + "name": "props", + "flags": 33554433, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 78, + "character": 16 + }, + "end": { + "line": 78, + "character": 21 + } + } + } + } + ] + }, + "id": "1" + } + ], + "returnType": { + "kind": "object", + "properties": [ + { + "kind": "max_depth", + "id": "14" + } + ], + "indexInfos": [], + "objectClass": { + "kind": "max_depth", + "id": "14" + }, + "symbolMeta": { + "name": "Component", + "flags": 96, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 429, + "character": 14 + }, + "end": { + "line": 429, + "character": 23 + } + } + } + }, + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 430, + "character": 10 + }, + "end": { + "line": 430, + "character": 19 + } + } + } + } + ] + }, + "typeArguments": [ + { + "kind": "max_depth", + "id": "14" + } + ], + "id": "11" + } + } + ], + "symbolMeta": { + "name": "__type", + "flags": 2048, + "anonymous": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 78, + "character": 11 + }, + "end": { + "line": 78, + "character": 48 + } + } + } + } + ] + }, + "id": "10" + } + ], + "id": "8" + }, + "defaultType": { + "kind": "reference", + "id": "8" + }, + "symbolMeta": { + "name": "T", + "flags": 262144, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 36 + }, + "end": { + "line": 139, + "character": 37 + } + } + } + } + ] + }, + "id": "7" + } + ], + "typeArguments": [ + { + "kind": "reference", + "id": "1" + }, + { + "kind": "reference", + "id": "1" + } + ], + "id": "5" + }, + "implementsTypes": [], + "constructSignatures": [], + "symbolMeta": { + "name": "a", + "flags": 2, + "declarations": [ + { + "location": { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 4, + "character": 6 + }, + "end": { + "line": 4, + "character": 7 + } + } + } + } + ] + }, + "aliasSymbolMeta": { + "name": "Element", + "flags": 64, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 3121, + "character": 18 + }, + "end": { + "line": 3121, + "character": 25 + } + } + } + } + ] + }, + "id": "0" +} +> +> Comp --- { + "kind": "function", + "signatures": [ + { + "symbolMeta": { + "name": "Comp", + "flags": 16, + "declarations": [ + { + "location": { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 9 + }, + "end": { + "line": 0, + "character": 13 + } + } + } + } + ] + }, + "parameters": [ + { + "kind": "object", + "properties": [ + { + "kind": "primitive", + "primitive": "string", + "symbolMeta": { + "name": "abc", + "flags": 4, + "declarations": [ + { + "location": { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 23 + }, + "end": { + "line": 0, + "character": 26 + } + } + } + } + ] + }, + "id": "2" + }, + { + "kind": "primitive", + "primitive": "number", + "symbolMeta": { + "name": "ad", + "flags": 16777220, + "declarations": [ + { + "location": { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 36 + }, + "end": { + "line": 0, + "character": 38 + } + } + } + } + ] + }, + "id": "3" + } + ], + "indexInfos": [], + "symbolMeta": { + "name": "props", + "flags": 1, + "declarations": [ + { + "location": { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 14 + }, + "end": { + "line": 0, + "character": 19 + } + } + } + } + ] + }, + "id": "1" + } + ], + "returnType": { + "kind": "interface", + "properties": [ + { + "kind": "primitive", + "primitive": "any", + "symbolMeta": { + "name": "type", + "flags": 33554436, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 140, + "character": 8 + }, + "end": { + "line": 140, + "character": 12 + } + } + } + } + ] + }, + "id": "5" + }, + { + "kind": "reference", + "symbolMeta": { + "name": "props", + "flags": 33554436, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 141, + "character": 8 + }, + "end": { + "line": 141, + "character": 13 + } + } + } + } + ] + }, + "id": "5" + }, + { + "kind": "union", + "types": [ + { + "kind": "primitive", + "primitive": "string", + "id": "7" + }, + { + "kind": "primitive", + "primitive": "number", + "id": "8" + } + ], + "symbolMeta": { + "name": "key", + "flags": 33554436, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 142, + "character": 8 + }, + "end": { + "line": 142, + "character": 11 + } + } + } + } + ] + }, + "aliasSymbolMeta": { + "name": "Key", + "flags": 524288, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 123, + "character": 9 + }, + "end": { + "line": 123, + "character": 12 + } + } + } + } + ] + }, + "id": "6" + } + ], + "baseType": { + "kind": "object", + "properties": [ + { + "kind": "reference", + "symbolMeta": { + "name": "type", + "flags": 33554436, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 140, + "character": 8 + }, + "end": { + "line": 140, + "character": 12 + } + } + } + } + ] + }, + "id": "5" + }, + { + "kind": "reference", + "symbolMeta": { + "name": "props", + "flags": 33554436, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 141, + "character": 8 + }, + "end": { + "line": 141, + "character": 13 + } + } + } + } + ] + }, + "id": "5" + }, + { + "kind": "union", + "types": [ + { + "kind": "reference", + "id": "7" + }, + { + "kind": "reference", + "id": "8" + } + ], + "symbolMeta": { + "name": "key", + "flags": 4, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 142, + "character": 8 + }, + "end": { + "line": 142, + "character": 11 + } + } + } + } + ] + }, + "aliasSymbolMeta": { + "name": "Key", + "flags": 524288, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 123, + "character": 9 + }, + "end": { + "line": 123, + "character": 12 + } + } + } + } + ] + }, + "id": "16" + } + ], + "indexInfos": [], + "symbolMeta": { + "name": "ReactElement", + "flags": 64, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 14 + }, + "end": { + "line": 139, + "character": 26 + } + } + } + } + ] + }, + "typeParameters": [ + { + "kind": "type_parameter", + "defaultType": { + "kind": "reference", + "id": "5" + }, + "symbolMeta": { + "name": "P", + "flags": 262144, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 27 + }, + "end": { + "line": 139, + "character": 28 + } + } + } + } + ] + }, + "id": "10" + }, + { + "kind": "type_parameter", + "baseConstraint": { + "kind": "union", + "types": [ + { + "kind": "reference", + "id": "7" + }, + { + "kind": "function", + "signatures": [ + { + "symbolMeta": { + "name": "__type", + "flags": 2048, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 77, + "character": 11 + }, + "end": { + "line": 77, + "character": 54 + } + } + } + } + ] + }, + "parameters": [ + { + "kind": "max_depth", + "id": "14" + } + ], + "returnType": { + "kind": "max_depth", + "id": "14" + } + } + ], + "symbolMeta": { + "name": "__type", + "flags": 2048, + "anonymous": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 77, + "character": 11 + }, + "end": { + "line": 77, + "character": 54 + } + } + } + } + ] + }, + "id": "13" + }, + { + "kind": "function", + "signatures": [ + { + "symbolMeta": { + "name": "__type", + "flags": 2048, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 78, + "character": 11 + }, + "end": { + "line": 78, + "character": 48 + } + } + } + } + ] + }, + "parameters": [ + { + "kind": "max_depth", + "id": "14" + } + ], + "returnType": { + "kind": "max_depth", + "id": "14" + } + } + ], + "symbolMeta": { + "name": "__type", + "flags": 2048, + "anonymous": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 78, + "character": 11 + }, + "end": { + "line": 78, + "character": 48 + } + } + } + } + ] + }, + "id": "15" + } + ], + "id": "12" + }, + "defaultType": { + "kind": "reference", + "id": "12" + }, + "symbolMeta": { + "name": "T", + "flags": 262144, + "insideClassOrInterface": true, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 139, + "character": 36 + }, + "end": { + "line": 139, + "character": 37 + } + } + } + } + ] + }, + "id": "11" + } + ], + "typeArguments": [ + { + "kind": "reference", + "id": "5" + }, + { + "kind": "reference", + "id": "5" + } + ], + "id": "9" + }, + "implementsTypes": [], + "constructSignatures": [], + "symbolMeta": { + "name": "Element", + "flags": 64, + "declarations": [ + { + "location": { + "fileName": "../node_modules/@types/react/index.d.ts", + "range": { + "start": { + "line": 3121, + "character": 18 + }, + "end": { + "line": 3121, + "character": 25 + } + } + } + } + ] + }, + "id": "4" + } + } + ], + "isJSXElement": true, + "symbolMeta": { + "name": "Comp", + "flags": 16, + "declarations": [ + { + "location": { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 0, + "character": 9 + }, + "end": { + "line": 0, + "character": 13 + } + } + } + } + ] + }, + "id": "0" +} +> abc="asc" ad={4} +> abc="asc" ad={4} +> abc="asc" +> abc --- { + "kind": "primitive", + "primitive": "string", + "symbolMeta": { + "name": "abc", + "flags": 4, + "declarations": [ + { + "location": { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 4, + "character": 16 + }, + "end": { + "line": 4, + "character": 19 + } + } + } + } + ] + }, + "id": "0" +} +> ad={4} +> ad --- { + "kind": "primitive", + "primitive": "number", + "symbolMeta": { + "name": "ad", + "flags": 4, + "declarations": [ + { + "location": { + "fileName": "cases/jsxFunctionComponent.tsx", + "range": { + "start": { + "line": 4, + "character": 26 + }, + "end": { + "line": 4, + "character": 28 + } + } + } + } + ] + }, + "id": "0" +} \ No newline at end of file diff --git a/tests/cases/jsxFunctionComponent.tsx b/tests/cases/jsxFunctionComponent.tsx new file mode 100644 index 0000000..7324059 --- /dev/null +++ b/tests/cases/jsxFunctionComponent.tsx @@ -0,0 +1,5 @@ +function Comp(props: { abc: string, ad?: number }) { + return <> +} + +const a = \ No newline at end of file diff --git a/tests/lib/baselineGenerators.ts b/tests/lib/baselineGenerators.ts index f72e0f4..f6ea223 100644 --- a/tests/lib/baselineGenerators.ts +++ b/tests/lib/baselineGenerators.ts @@ -55,8 +55,10 @@ function getTypeInfoRetriever(ctx: SourceFileTypescriptContext) { assert(sourceFile) const { line, character } = location.range.start + const node = getDescendantAtPosition( ctx, + sourceFile, sourceFile.getPositionOfLineAndCharacter(line, character) ) diff --git a/tests/lib/baselines.ts b/tests/lib/baselines.ts index 8c38031..700e59d 100644 --- a/tests/lib/baselines.ts +++ b/tests/lib/baselines.ts @@ -17,6 +17,8 @@ function getTestGlob(): string | undefined { return process.env["TESTS"] } +const allowedExtensions = [".ts", ".tsx"] + export async function getTestCases(): Promise { const globbed = await new Promise((resolve, reject) => { glob(getTestGlob() ?? "*", { cwd: testCasePath }, (err, files) => { @@ -27,8 +29,10 @@ export async function getTestCases(): Promise { }) }) - return globbed.filter( - (name) => path.parse(name).ext.toLowerCase() === ".ts" + return globbed.filter((name) => + allowedExtensions.some( + (ext) => path.parse(name).ext.toLowerCase() === ext + ) ) } diff --git a/tsconfig.json b/tsconfig.json index 72ad218..c561189 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,6 +9,8 @@ "exclude": ["**/node_modules", "**/dist"], "compilerOptions": { "esModuleInterop": true, - "resolveJsonModule": true + "resolveJsonModule": true, + "jsx": "react", + "sourceMap": true } } diff --git a/yarn.lock b/yarn.lock index c925066..0850f05 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1177,6 +1177,25 @@ resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0" integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA== +"@types/prop-types@*": + version "15.7.5" + resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.5.tgz#5f19d2b85a98e9558036f6a3cacc8819420f05cf" + integrity sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w== + +"@types/react@^18.0.24": + version "18.0.24" + resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.24.tgz#2f79ed5b27f08d05107aab45c17919754cc44c20" + integrity sha512-wRJWT6ouziGUy+9uX0aW4YOJxAY0bG6/AOk5AW5QSvZqI7dk6VBIbXvcVgIw/W5Jrl24f77df98GEKTJGOLx7Q== + dependencies: + "@types/prop-types" "*" + "@types/scheduler" "*" + csstype "^3.0.2" + +"@types/scheduler@*": + version "0.16.2" + resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.2.tgz#1a62f89525723dde24ba1b01b092bf5df8ad4d39" + integrity sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew== + "@types/semver@^7.3.12": version "7.3.12" resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.3.12.tgz#920447fdd78d76b19de0438b7f60df3c4a80bf1c" @@ -2119,6 +2138,11 @@ css-what@^6.1.0: resolved "https://registry.yarnpkg.com/css-what/-/css-what-6.1.0.tgz#fb5effcf76f1ddea2c81bdfaa4de44e79bac70f4" integrity sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw== +csstype@^3.0.2: + version "3.1.1" + resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.1.tgz#841b532c45c758ee546a11d5bd7b7b473c8c30b9" + integrity sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw== + dargs@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/dargs/-/dargs-7.0.0.tgz#04015c41de0bcb69ec84050f3d9be0caf8d6d5cc"