Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

RefTypes inside Interface does not expand correctly in Typescript

オープン
#366 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
react, typescript
領域
tooling

調査の方向性

fixtures_23.tsx にある変更済みのインターフェース例から始め、TSComponent 用に生成された JSON を再現してください。props.something に対して BaseProps インターフェースがどのように表現されるかを追跡してください。出力に BaseProps という名前だけでなくインターフェース定義が含まれ、既存の baz の出力が維持されていれば完了です。

索引モデルが issue の本文から書いたものです。

説明

typescript

Original Example (fixtures_23.tsx)

/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 */

import React, { Component } from 'react';

type BaseProps = {
  /** Optional prop */
  foo?: string,
  /** Required prop */
  bar: number
};

type TransitionDuration = number | { enter?: number, exit?: number } | 'auto';

type Props = BaseProps & {
  /** Complex union prop */
  baz: TransitionDuration
}

/**
 * This is a typescript class component
 */
export default class TSComponent extends Component<Props> {
  render() {
    return <h1>Hello world</h1>;
  }
}

The output for the above example seems to be generated correctly.

Modified example with interfaces

import React, { Component } from "react";

interface BaseProps {
  /** Optional prop */
  foo?: string;
  /** Required prop */
  bar: number;
}

type TransitionDuration = number | { enter?: number; exit?: number } | "auto";

interface Props {
  something: BaseProps;
  /** Complex union prop */
  baz: TransitionDuration;
}

/**
 * This is a typescript class component
 */
export default class TSComponent extends Component<Props> {
  render() {
    return <h1>Hello world</h1>;
  }
}
Output
{
	"description": "This is a typescript class component",
	"displayName": "TSComponent",
	"methods": [],
	"props": {
		"something": {
			"required": true,
			"tsType": {
				"name": "BaseProps"
			},
			"description": ""
		},
		"baz": {
			"required": true,
			"tsType": {
				"name": "union",
				"raw": "number | { enter?: number; exit?: number } | \"auto\"",
				"elements": [{
					"name": "number"
				}, {
					"name": "signature",
					"type": "object",
					"raw": "{ enter?: number; exit?: number }",
					"signature": {
						"properties": [{
							"key": "enter",
							"value": {
								"name": "number",
								"required": false
							}
						}, {
							"key": "exit",
							"value": {
								"name": "number",
								"required": false
							}
						}]
					}
				}, {
					"name": "literal",
					"value": "\"auto\""
				}]
			},
			"description": "Complex union prop"
		}
	}
}
Issue

props.something in the above output has only the name and not the interface which is defines.

主要言語
TypeScript
スター
3.8k
フォーク
316
平均マージ
3時間 28分
マージ済み PR(30日)
6

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

reactjs/react-docgen のほかの issue

reactjs/react-docgen の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。