vs 代码智能感知不适用于 webpack 包 [英] vs code IntelliSense not working with webpack bundles

查看:35
本文介绍了vs 代码智能感知不适用于 webpack 包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的 webpack 配置.

I have a simple webpack config .

const path = require('path');

module.exports = {
  devtool: 'source-map',
  entry: './src/index.js',
  output: {
    libraryTarget: 'commonjs',
    filename: 'index.js',
    path: path.resolve(__dirname, 'dist'),
  },
};

在我构建并将我的模块上传到 npm 并将它们用于其他项目后,vs 代码 IntelliSense 不适用于这些模块.模块功能用 jsdoc 记录.

After I build and upload my modules to npm and use them on other projects the vs code IntelliSense is not working for these modules. The module functions are documented with jsdoc.

import { myFunc } from 'myModule';

const myModule = require('myModule');

Myfunc 和 myModule 没有 IntelliSense 自动编译支持或任何其他支持.

Myfunc and myModule have no IntelliSense auto complate support or any other.

如何在 webpack 构建后保持 jsdoc 正常工作?

How can I keep the jsdoc working after webpack build?

推荐答案

如果包是通过 npm 来的,你需要发布一个类型定义文件(.d.ts).d.ts 文件包含 API 的类型定义和注释,使我们能够有效地为外部包提供丰富的智能感知.VS Code 在解析 node_modules 包中的实际 JS 代码方面受到限制.

If the package is coming through npm, you need to publish a type definition file (.d.ts). d.ts files contain type definitions and comments for your API that allow us to efficiently provide rich intellisense for external packages. VS Code is limited in how it can parse the actual JS code from node_modules packages.

以下是有关 d.ts 文件入门的一些资源:

Here's some resources on getting started with d.ts files:

这篇关于vs 代码智能感知不适用于 webpack 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆