git - 如何在 git 子模块中配置 tsconfig 文件?#forTsChecker
问题描述
我有这个项目,在这个项目中,我有一个 git 子模块作为共享组件,结构如下。
Porject
├─node_modules
├─src
│ ├─App
│ ├─common
│ │ ├─Components
├─CommonUI <== sub module
│ ├─.storybook
│ ├─node_modules
│ ├─src
│ │ ├─Components
│ ├─index.ts
│ └─tsconfig.json
├─tsconfig.json
├─webpack.config.js
└─typings
如果我在 git Shubmodule 中安装依赖项,主项目会出错。
输入 '{ onChange: (e: any) => void; 类型:字符串;检查:布尔值;类名:字符串;形式?:字符串 | 不明确的; 插槽?:字符串 | 不明确的; 样式:CSS 属性 | 不明确的; 标题?:字符串 | 不明确的; ... 274 更多 ...; 步骤?:字符串 | ... 1 更多 ... | 不明确的; }' 不可分配给类型 'DetailedHTMLProps<InputHTMLAttributes, HTMLInputElement>'。输入 '{ onChange: (e: any) => void; 类型:字符串;检查:布尔值;类名:字符串;形式?:字符串 | 不明确的; 插槽?:字符串 | 不明确的; 样式?: CSSProperties | 不明确的; 标题?:字符串 | 不明确的; ... 274 更多 ...; 步骤?:字符串 | ... 1 更多 ... | 不明确的; }' 不可分配给类型 'InputHTMLAttributes'。属性“样式”的类型不兼容。输入'import("MainProject/CommonUI/node_modules/@types/react/index")。CSS 属性 | undefined' 不可分配给类型 'React.CSSProperties | 不明确的'。
但是如果我在 git submodel 中删除 node_modules ,则不会出现此错误。我会很好地构建我的项目。
在主项目中 tsconfig.json 是这样的
{
"ts-node": {
"compilerOptions": {
"module": "CommonJS"
}
},
"compilerOptions": {
"outDir": "./dist",
"baseUrl": ".",
"noImplicitAny": false,
"target": "ESNext",
"module": "ESNext",
"noLib": false,
"moduleResolution": "node",
"sourceMap": true,
"jsx": "react",
"allowJs": true,
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"importsNotUsedAsValues": "preserve",
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"checkJs": false,
"paths": {
"@/*": ["./src/*"],
"@Common/UI": ["gitSubmodule/src"]
}
},
"exclude": ["node_modules", "dist"],
"include": ["src/**/*", "typings", "SunglinkUI"]
}
这是 git 子模块中的 tsconfig 文件。
{
"extends": "../tsconfig.json",
"include": ["src/**/*"]
}
重点是为什么?为什么在我安装一些依赖项时删除 git 子模块中的 node_modules 可以但不行
解决方案
推荐阅读
- ios - 如何动态更新 Json 文件 swift 5
- python - 不一致的 Python 结果
- python - AttributeError:validation_data 无法在自定义回调中访问
- javascript - 与 BehaviorSubject 共享服务未发出正确值
- spring - 连接 InternalResourceViewResolver 时出现 NoUniqueBeanDefinitionException
- ruby-on-rails - 循环使用 gmail api 读取正文
- android - Android 下载管理器在 androidX kotlin 中给出 400 'placeholder' 错误
- javascript - 向 HH:MM:SS 添加秒数
- c# - 从 C# 模块调用 C++ 函数会引发随机崩溃
- python - 无法在在线 Jupyter 笔记本中导入 csv 文件