- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在进行一些 Angular 测试,我的规范文件无法识别我的路径,它们在 VS Code 中给我一个红色波浪线导入警告(并出现在问题中),尽管它们以其他方式工作(测试作品等)。我假设这是一个 tsconfig 问题而不是 linting 问题,因为它给我的错误是:Cannot find module '@feature/<reference path>.<file type>'.ts(2307)
它在功能上对我影响不大,但它很烦人(并且会杀死自动导入)。
tsconfig.json:
{
"compileOnSave": false,
"compilerOptions": {
"module": "esnext",
"outDir": "./dist/out-tsc",
"strictNullChecks": true,
"noImplicitAny": false,
"noImplicitThis": true,
"alwaysStrict": false,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"skipLibCheck": true,
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowJs": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"target": "es2015",
"types": [
"node",
"arcgis-js-api",
"jest"
],
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom",
"esnext.asynciterable"
],
"baseUrl": ".",
"paths": {
"core-js/es6/*": [
"node_modules/core-js/es/*"
],
"core-js/es7/reflect": [
"node_modules/core-js/proposals/reflect-metadata"
],
"@core/*": [
"src/app/core/*"
],
"@shared/*": [
"src/app/shared/*"
],
"@feature/*": [
"src/app/feature/*"
],
"@test/*": [
"src/test/*"
],
"@/*": [
"src/*"
]
}
},
"files": [
"src/main.ts",
"src/polyfills.ts"
],
"include": [
"**/*.d.ts"
]
}
tsconfig.spec.json 和 tsconfig.app.json 路径(注意来自 angular-cli 的标准文件夹结构):
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/spec"
}
}
Angular .json
...
"test": {
"builder": "@angular-builders/jest:run",
"options": {
"tsConfig": "src/tsconfig.spec.json",
"no-cache": true,
"polyfills": "src/polyfills.ts",
"configPath": "./jest.config.js",
"styles": [
"node_modules/font-awesome/css/font-awesome.css",
"src/styles.scss"
],
"scripts": [],
"assets": [
"src/favicon.ico",
"src/assets",
"src/manifest.json",
],
"stylePreprocessorOptions": {
"includePaths": [
"src"
]
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
...
版本:
Angular CLI: 8.3.6
Node: 12.3.1
OS: win32 x64
Angular: 8.2.8
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router, service-worker
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.803.6
@angular-devkit/build-angular 0.803.6
@angular-devkit/build-optimizer 0.803.6
@angular-devkit/build-webpack 0.803.6
@angular-devkit/core 8.3.6
@angular-devkit/schematics 8.3.6
@angular/cli 8.3.6
@angular/pwa 0.803.6
@ngtools/webpack 8.3.6
@schematics/angular 8.3.6
@schematics/update 0.803.6
rxjs 6.5.3
typescript 3.5.3
webpack 4.39.2
最佳答案
我想这个问题与您的 files
有关和 include
配置。当我包括你相当有限的一组 files
和 include
我立即看到了您描述的相同问题,原因很简单,并非我的所有文件都匹配 *.d.ts
.
要查看这是否是导致您出现问题的原因(或者如果您知道您的文件与 *.d.ts
不匹配),我建议您先删除您的 files
和 include
部分,节省 tsconfig.json
并在 VS Code 中重启 TS 服务器。
对于那些不知道的人,您可以通过打开命令面板(Ctrl+Shift+P
或 ⌘+Shift+P 或只是 F1) .ts
文件并输入 Restart TS
并选择该命令。
如果那个是适合您的解决方案,那么您只需要考虑在files
中您实际需要什么。和 include
. documentation应该在这方面有所帮助。
最大的收获:您不需要它们中的任何一个:
If the "files" and "include" are both left unspecified, the compiler defaults to including all TypeScript (.ts, .d.ts and .tsx) files in the containing directory and subdirectories except those excluded using the "exclude" property. JS files (.js and .jsx) are also included if allowJs is set to true.
如果您确实需要这种特异性,您可能只需要添加 *.ts
和\或 *.tsx
include
的图案解决问题的模式。
希望对您有所帮助!
关于.spec 文件中无法识别 Angular 8+ tsconfig 路径别名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58122806/
Hi得到了一个对我来说似乎有效的YAML,但当应用它时它不起作用,我不知道它有什么问题。错误:。Kubeval部署.yaml通过,没有错误
当我通过“rake spec”运行它时,我的一个规范失败了,但当我使用 RSpec 可执行文件“spec”时,它通过了。当我在 ActionMailer View 中使用 url 帮助器时,规范失败。
我对码头公司还是个新手。我使用的是最新版本的Python、Django和Docker。我已经在这个项目上工作了两周了,我已经创建了docker-compose.yml文件,并且已经构建了我的docke
我正在遵循 clojure.spec 的指南 ( http://clojure.org/guides/spec )。我对序列规范的 alt 和 or 之间的差异感到困惑。 对我来说,以下两个示例同样有
当我在我的 Rails 项目中运行 rake spec 时,它会执行所有规范,然后尝试运行测试(如 rake test): $ rake spec ruby -S rspec ./spec/... #
Nestjs:如果 --no-spec 用于禁用规范文件生成,如何生成“spec.ts”文件。我需要测试完整的模块,但我没有 spec.ts 文件。是否有任何机制可以为现有模块生成这些文件。 最佳答案
我是 erlang 编程的新手。我有很多疑问。其中之一是使用-spec。 “-spec”在 Erlang 语法中有什么作用?使用或不使用 -spec 创建函数有什么区别 没有 -spec 的功能 ad
我需要验证已从 json 字符串转换的 clojure 映射的形状。 json 字符串是我正在实现的协议(protocol)的消息。 为此,我正在尝试 clojure.spec.alpha。 我正在使
有没有办法在另一个函数规范中引用一个函数的返回类型规范? defmodule Car do @spec beep(none()) :: String.t def beep do "be
出于学习目的,我正在尝试将 Chef 解释器项目转换为 python 3.4,并尝试将涉及的库转换为最新版本,但是当涉及到 funcparserlib 时,我有点不知所措。 这是 Chef 脚本: f
我正在将一堆旧脚本转换为 Jenkins 管道作业。对于我们的许多脚本,我们使用 JFrog CLI 来处理与 Artifactory 的所有交互。有了 Jenkins 管道,我们现在可以选择通过 A
我使用 RSpec 设置了一个新的 Rails 4 应用程序。但是运行时rake rspec ,所有示例都运行两次: rake spec [deprecated] I18n.enforce_avail
我有 Kubernetes 部署 的 list 。当我尝试从 Azure Devops 部署它时,出现以下错误: error: error validating "/home/vsts/work/r1
为什么使用 Combine(...) 保留空格,而 Keyword(...) 删除这些空格? 我需要保留匹配标记后面的空格。 测试如下: from pyparsing import * def par
以下是使用 time rspec spec 进行的 3 次随机运行对比time bundle exec spec在一个相当简单的 Rails 3 应用程序上。不使用 bundler 始终更快,并且它使
我修改了 Github 上的一个 repo 以集成我的库的 swift 版本。 https://github.com/iDevelopper/PBRevealViewController 然而,当我在
我在 Rails 3.2 上,我正在使用 rspec (2.11.1)。当我使用“rake spec”运行我的测试套件时,我会失败。当我用“rspec”运行它时,一切都过去了。我已经看到其他人提到这个
我正在第二次学习 Rails 教程。当我输入这个 rails generate integration_test static_pages 我得到 spec/rails_helper.rb 和 spe
我正在尝试通过 https 向服务器验证我的客户端应用程序 - 我正在使用 axis 1.4 jar。我将正确的 JKS 文件传递给信任库。但是,我收到以下异常。 Caused by: ja
我一直在尝试使用HELM UPGRADE创建POD: helm upgrade --values=$(System.DefaultWorkingDirectory)/_NAME-deploy-CI/d
我是一名优秀的程序员,十分优秀!