安装打字稿后,为什么要“窥视定义”。在Visual Studio代码中停止工作?
我是Typescript的新手,并且正在尝试弄清为什么在将项目转换为Visual Studio Code中的打字稿时,“ PEEK定义”停止工作。
在过渡到打字稿之前,我正在使用jsconfig.json
来设置WebPack别名。添加Typescript后,我使用tsconfig.json
来做同样的事情,而我尚不完全了解其他配置选项。
没有打字稿,当徘徊在组件上时,我会看到类似的内容,
(alias) module ComponentWrapper
(alias) const ComponentWrapper: {
({ children }: {
children: any;
}): JSX.Element;
displayName: string;
propTypes: {
something: PropTypes.Requireable<string>;
};
defaultProps: {};
}
import ComponentWrapper
而CMD + Click会将我带到该文件。但是,在打字稿项目中,执行同样的事情,当悬停时,我会看到
import ComponentWrapper
和cmd + click只需将我带到文件的顶部到import
语句。
我的jsconfig.json
看起来
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@components/*": ["src/components/*"],
"@modules/*": ["src/modules/*"],
"@utils/*": ["src/utils/*"]
}
}
}
像我的tsconfig.json
看起来
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@components/*": ["src/components/*"],
"@modules/*": ["src/modules/*"],
"@utils/*": ["src/utils/*"]
},
"allowJs": true,
"checkJs": false,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"jsx": "preserve",
"lib": ["dom", "dom.iterable", "es2017"],
"module": "commonjs",
"moduleResolution": "node",
"noEmit": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"preserveConstEnums": true,
"removeComments": false,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": false,
"target": "ES2019",
"incremental": true
},
"exclude": [".github", ".next", "node_modules", "public"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
}
我怎么了?
I'm very new to TypeScript and am trying to figure why, when transitioning a project to TypeScript in Visual Studio Code, "Peek Definition" stops working.
Before transitioning to TypeScript, I'm using jsconfig.json
to set up Webpack aliases. After adding TypeScript, I'm using tsconfig.json
to do the same thing, with additional configuration options I don't fully understand yet.
Without TypeScript, when hovering over a component, I'll see something like,
(alias) module ComponentWrapper
(alias) const ComponentWrapper: {
({ children }: {
children: any;
}): JSX.Element;
displayName: string;
propTypes: {
something: PropTypes.Requireable<string>;
};
defaultProps: {};
}
import ComponentWrapper
And CMD + click will take me to that file. However, in the TypeScript project, doing the same thing, when hovering I see
import ComponentWrapper
And CMD + click just takes me to the top of the file to the import
statement.
My jsconfig.json
looks like
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@components/*": ["src/components/*"],
"@modules/*": ["src/modules/*"],
"@utils/*": ["src/utils/*"]
}
}
}
While my tsconfig.json
looks like
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@components/*": ["src/components/*"],
"@modules/*": ["src/modules/*"],
"@utils/*": ["src/utils/*"]
},
"allowJs": true,
"checkJs": false,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"jsx": "preserve",
"lib": ["dom", "dom.iterable", "es2017"],
"module": "commonjs",
"moduleResolution": "node",
"noEmit": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"preserveConstEnums": true,
"removeComments": false,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": false,
"target": "ES2019",
"incremental": true
},
"exclude": [".github", ".next", "node_modules", "public"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
}
What am I getting wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论