typescript - Is it possible to mimic webpack custom module resolution in TypeScript?
问题描述
I can't find out how to make TS check for modules not only node_modules directory but other custom directories too.
My situation:
# webpack config
resolve: {
modules: ['components', 'node_modules']
}
# index.vue
import WorkspaceToolbar from 'WorkspaceToolbar' // TS can't find this module since it doesn't look in components dir.
So, is it possible to make TS check for modules like webpack does?
解决方案
I solved the problem. It was due to a lack of knowledge of TS. To find modules I just need to declare them using declare module
in *.d.ts
files.
推荐阅读
- algorithm - 多变量函数的局部最大值搜索
- python - 我正在尝试从 HTML 文件中获取文本,但我不知道如何(谷歌搜索但 idk 在哪里查看)
- flutter - 如何将 ontap 功能添加到 gridview 中的每个容器
- python - 当一个符号和一组符号可能具有不同的值时,如何获得所有可能的组合
- vue.js - bootstrap-vue 复选框选择全部或无
- java - 如何以编程方式更改 jTable 中的单元格?
- c++ - 运算符 << 为 std::endl 操作加载的 API?
- pytorch - 如何获取训练 pytorch 模型的 imagenet 数据集
- android - Flutter Firebase 通知 onlunch 不起作用
- amazon-web-services - 本地:使用 AWS MSK 集群和 Confluent.Kafka nuget 包时出现消息超时错误