这个问题是否在所有扩展都被禁用时发生?:是/否
重现步骤:
FC
qaxu7uf21#
请分享一个最小的、自包含的代码示例。
vql8enpb2#
// Component.ts import { FC } from "react"; export const Component: FC = () => <span>Hello World</span>; // App.ts import { Component } from "./Component"; import { FC } from "react"; export const App: FC = () => <Component />; export default App;
now cmd click Component inside App.ts and you land on line 1098 of file react/node_modules/@types/react/index.d.tswhere the code is
react/node_modules/@types/react/index.d.ts
// ... interface FunctionComponent<P = {}> { (props: P, context?: any): ReactNode; // ...
bz4sfanl3#
这并不总是发生。我无法说出这两者之间的区别,但其中一个有效而另一个无效:
$x_1a^0b^1x$
kg7wmglp4#
添加这也发生在我身上,如果你定义了一个用forwardRef或memo Package 的组件。快速演示:vscode-bug-maybe.mov
forwardRef
memo
function NormalComponent() { return <div />; } const FCComponent: React.FC = () => { return <div />; }; const MemoComponent = React.memo(() => { return <div />; }); const ForwardRefComponent = React.forwardRef<any, any>((props, ref) => { return <div ref={ref} />; }); function Comp() { return ( <> {/* goes to the function definition as expected */} <NormalComponent /> {/* goes to the React type definition :( */} <FCComponent /> <MemoComponent /> <ForwardRefComponent /> </> ); }
ahy6op9u5#
这对我来说似乎非常不一致。我正在使用mobx状态树,但它也发生在非观察组件上,有时并不发生在观察组件上。
s4chpxco6#
对于我来说,情况并非如此,正如@yspreen所指出的,这种情况似乎并不一致。我将editor.preferGoToSourceDefinition切换为true,似乎有时会产生差异。
editor.preferGoToSourceDefinition
true
g9icjywg7#
我无法复现这些情况,要么是因为信息不足,要么是因为展示的问题(例如第二次点击MemoComponent)没有发生。
s3fp2yjn8#
我可以提供哪些信息来帮助复现问题?
ruyhziif9#
最好的情况是我们可以克隆一个仓库,再附上一套说明文档,展示问题所在。
9条答案
按热度按时间qaxu7uf21#
请分享一个最小的、自包含的代码示例。
vql8enpb2#
now cmd click Component inside App.ts and you land on line 1098 of file
react/node_modules/@types/react/index.d.ts
where the code is
bz4sfanl3#
这并不总是发生。我无法说出这两者之间的区别,但其中一个有效而另一个无效:
$x_1a^0b^1x$
kg7wmglp4#
添加这也发生在我身上,如果你定义了一个用
forwardRef
或memo
Package 的组件。快速演示:
vscode-bug-maybe.mov
ahy6op9u5#
这对我来说似乎非常不一致。我正在使用mobx状态树,但它也发生在非观察组件上,有时并不发生在观察组件上。
s4chpxco6#
对于我来说,情况并非如此,正如@yspreen所指出的,这种情况似乎并不一致。我将
editor.preferGoToSourceDefinition
切换为true
,似乎有时会产生差异。g9icjywg7#
我无法复现这些情况,要么是因为信息不足,要么是因为展示的问题(例如第二次点击MemoComponent)没有发生。
s3fp2yjn8#
我可以提供哪些信息来帮助复现问题?
ruyhziif9#
最好的情况是我们可以克隆一个仓库,再附上一套说明文档,展示问题所在。