【问题标题】:VSCode, how do I hide specified typings and suggestions in typescript?VSCode,如何在打字稿中隐藏指定的类型和建议?
【发布时间】:2021-03-20 05:39:37
【问题描述】:

问题1;

你好,我正在使用 typescript 和 VSCode,我安装了“@material-ui/core”和“@emotion”这两个包,它们都是这样导出“样式”的。

import { styled } from '@material-ui/core'
import styled from '@emotion/styled/types/base'

图片:从@material-ui/core 导出样式

图片:从@emotion 导出样式

我想隐藏「@material-ui/core」的「styled」建议,保留「@emotion」。

我如何做到这一点?

问题2;

「aria-*」道具的惊人的「@material-ui/core」支持日志,但在我的情况下,我绝对不需要那些道具,我怎样才能让它不建议?

图片:aria-*的道具

【问题讨论】:

    标签: typescript visual-studio-code autosuggest


    【解决方案1】:

    第一季度: 您的其中一个导入必须使用导入别名,否则您将遇到变量名称冲突。

    import { styled } from '@material-ui/core'
    import styled as emotionStyled from '@emotion/styled/types/base'
    

    或者:

    import { styled as materialStyled } from '@material-ui/core'
    import styled from '@emotion/styled/types/base'
    

    第二季度: 理论上,您可以编辑此包的 d.ts 文件,其中包含 vscode 用于自动完成的类型。但是我不建议这样做,绝对不建议编辑一些第三方包代码。

    【讨论】:

    • 感谢您的回复,关于 Q1,我想取消建议 @material-ui/core 的“自动导入”,因此我不需要查看我更喜欢哪个进口。有可能吗?
    • “自动导入”是什么意思?
    • 当我触发“触发建议”命令时,您可以在这张图片中看到i.stack.imgur.com/0aTf0.png
    • 好的,我找到了一种在 d.ts 中声明模块“XXX”{}的方法
    猜你喜欢
    • 2018-05-24
    • 1970-01-01
    • 2017-02-20
    • 2021-06-02
    • 2018-06-04
    • 1970-01-01
    • 2023-01-30
    • 2017-01-16
    • 2019-09-07
    相关资源
    最近更新 更多