简体   繁体   English

VS Code 如何为每个单独的 Js 文件配置具有隔离类型系统的项目

[英]VS Code how to configure a project with isolated type system per individual Js file

The problem.问题。 I want to have a folder with multiple ES5 JavaScript files.我想要一个包含多个 ES5 JavaScript 文件的文件夹。

By default the JavaScript/Typescript workspace treats all files as a single project, so variables defined in one js file are visible in any other file in the project.默认情况下,JavaScript/Typescript 工作区将所有文件视为一个项目,因此在一个 js 文件中定义的变量在项目中的任何其他文件中都是可见的。

Unfortunately these files are used for scripting a desktop application and they are executed in different typing contexts, so sharing the variables is not be permitted.不幸的是,这些文件用于编写桌面应用程序的脚本,并且它们在不同的键入上下文中执行,因此不允许共享变量。

How to configure my workspace in VSCode, (eventually via an extension ) to achieve type system isolation between these files.如何在 VSCode 中配置我的工作区,(最终通过扩展)来实现这些文件之间的类型系统隔离。 I cannot use any type of module imports.我不能使用任何类型的模块导入。

Found the solution.找到了解决方案。 Put files in separate folders.将文件放在单独的文件夹中。 Create a jsconfig.json file in each folder with content {}.在每个文件夹中创建一个 jsconfig.json 文件,内容为 {}。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM