我有一个像这样的 tsconfig
{
"compileOnSave": false,
"compilerOptions": {
"module": "es2015",
"target": "es2015",
"sourceMap": true,
"jsx": "react",
"allowSyntheticDefaultImports": true,
"noImplicitAny": false,
"watch": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowJs": true,
"suppressOutputPathCheck": true
},
"exclude": [
"dist",
"node_modules",
"bower_components",
"typings/globals",
"typings/modules"
]
}
Run Code Online (Sandbox Code Playgroud)
我正在使用 webpack 来捆绑我的项目文件。大多数定义文件都是使用类型添加的,但某些 npm 模块包含自己的定义文件。我希望能够将它们添加到打字稿编译中。否则我会得到类似的错误Cannot find module X
如何在编译中包含这些定义文件?
我使用 CKEditor 设置了一个全新的 TYPO3 8.7.4 安装并rte_ckeditor_image
从 FAL 获取图像。
在rte_ckeditor_image
它的文档中说:
最大尺寸与必须在 Page TSConfig 中设置的魔术图像的配置有关:
Run Code Online (Sandbox Code Playgroud)# Page TSConfig RTE.default.buttons.image.options.magic { maxWidth = 1020 # Default: 300 maxHeight = 800 # Default: 1000 }
我这样做了,但仍然无法使图像的宽度大于 300 像素。
我已经看过TYPO3的源代码了。有一个文件typo3/sysext/core/Classes/Resource/Service/MagicImageService.php
有两个变量:$magicImageMaximumWidth
和$magicImageMaximumHeight
. 如果更改它们的值,我可以使图像的宽度大于 300 像素。
该文件还有一个函数setMagicImageMaximumDimensions(array $rteConfiguration)
,该函数应该更改两个变量,但似乎没有这样做。
我做错了什么还是无法更改最大图像尺寸?
谢谢。
我在 Angular 项目中遇到了一个奇怪的现象。
\n\n我的项目是从命令行自动生成的(ng new myproject)
\n\n在项目中,目录\xef\xbc\x9a
\n\n应用程序组件基.ts:
\n\nimport { AppSessionService } from \'@shared/session/app-session.service\';\n
Run Code Online (Sandbox Code Playgroud)\n\n和tsconfig.app.json:
\n\n"paths": {\n "@abp/*": [ "../node_modules/abp-ng2-module/src/*" ],\n "@app/*": [ "./app/*" ],\n "@shared/*": [ "./app/shared/*" ],\n "@node_modules/*": [ "../node_modules/*" ]\n}\n
Run Code Online (Sandbox Code Playgroud)\n\nvscode显示错误(不影响正常运行,但无法导航到该类)\xef\xbc\x9a
\n\n[ts] Cannot find module \'@shared/session/app-session.service\'.\n
Run Code Online (Sandbox Code Playgroud)\n\n我是否有任何配置错误?\n谢谢!
\n\n我知道可能是这样,但我想使用通用符号\xef\xbc\x9a
\n\nimport { AppSessionService } from \'../session/app-session.service\';\n\n\n\n@angular/cli: …
Run Code Online (Sandbox Code Playgroud) 我的打字稿编译抛出以下错误
TS2531:对象可能为“空”。
我正在转换带有大量此类错误的代码,只是想抑制它们以完成构建工作。据我了解,在 tsconfig.json 文件中添加以下内容可以抑制此错误。
“compilerOptions”:{“strictNullChecks”:false}
但是错误仍然显示。我找不到特定于此错误的任何其他编译器选项。有没有办法抑制它?
最近我将我的角度应用程序移动到了一些不同的文件夹中。从那时起,当我想构建应用程序时,我收到此错误:
架构验证失败并出现以下错误:数据路径“”应具有必需的属性“tsConfig”
我尝试在 github 和 stackoverflow 中查找,只找到了这些链接:
https://github.com/angular/angular-cli/issues/11479
他们说我必须降级一个包:
“@Angular-devkit/build-Angular”:“^0.800.1”到“^0.12.4”
但这感觉不是正确的方式
{
"name": "@xxx/ma",
"version": "1.1.0",
"private": true,
"license": "UNLICENSED",
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.conf.js",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"doc": "compodoc -p src/tsconfig.app.json -s"
},
"dependencies": {
"@angular/animations": "~8.2.1",
"@angular/cdk": "~8.2.1",
"@angular/common": "~8.2.1",
"@angular/compiler": "~8.2.1",
"@angular/core": "~8.2.1",
"@angular/flex-layout": "8.0.0-beta.27",
"@angular/forms": "~8.2.1",
"@angular/material": "~8.2.1",
"@angular/platform-browser": "~8.2.1",
"@angular/platform-browser-dynamic": "~8.2.1",
"@angular/platform-server": "~8.2.1",
"@angular/pwa": "~0.802.1",
"@angular/router": "~8.2.1",
"@angular/service-worker": "~8.2.1",
"@progress/kendo-angular-buttons": "~5.0.0", …
Run Code Online (Sandbox Code Playgroud) 编译 Angular 应用程序 (v10) 失败并出现此错误。
An unhandled exception occurred: tsconfig.json:14:5 - error TS5023: Unknown compiler option 'strictTemplates'.
14 "strictTemplates": true,
~~~~~~~~~~~~~~~~~
Run Code Online (Sandbox Code Playgroud) 这是一个奇怪的错误。所以我把 jest 更新到 27 然后全部停止工作
导入路径似乎有问题。所以下面的
import { something } form 'src/app/components/.....';
Run Code Online (Sandbox Code Playgroud)
不起作用,但这确实有效:
import { something } from '../../components/....';
Run Code Online (Sandbox Code Playgroud)
我猜这是在 tsconfig 中管理的。这是我的spec
tsconfig:
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/spec",
"types": [
"jest", // 1
"node",
"Chrome"
],
"esModuleInterop": true, // 2
"emitDecoratorMetadata": true, // 3
"allowSyntheticDefaultImports": true,
},
"files": ["src/test.ts", "src/polyfills.ts"],
"include": ["src/**/*.spec.ts", "src/**/*.d.ts"]
}
Run Code Online (Sandbox Code Playgroud)
和主要的 tsconfig:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true, …
Run Code Online (Sandbox Code Playgroud) 我为路径添加打字稿配置:
{
//.....
"moduleResolution": "node",
{
"baseUrl": "app",
"paths": {
"@app/*": ["*"],
"@folder/*": ["folder/*"],
//Other paths
},
Run Code Online (Sandbox Code Playgroud)
}
为 webpack 添加配置:
resolve: {
extensions: [".tsx", ".ts", ".js", ".jsx", ".css", ".json"],
alias: {
"@app":path.resolve(__dirname + "../", "app"),
"@services":path.resolve(__dirname + "../app", "folder")
},
modules: [
"node_modules", path.resolve(process.cwd(), "app")
],
plugins: [
new TsConfigPathsPlugin({
configFile: "../tsconfig.json"
}),
],
},
Run Code Online (Sandbox Code Playgroud)
这是我的 .eslint 文件:
"settings": {
"import/resolver": {
"node": {
"paths": [
"app"
],
"extensions": [
".ts",
".tsx",
".jest.tsx",
".d.ts"
]
}
}
Run Code Online (Sandbox Code Playgroud)
之后我尝试导入这样的东西:
import …
Run Code Online (Sandbox Code Playgroud) 在我更新软件包后,我看到了这个错误(同时我更新了我的 vs 代码)/我不知道如何修复这个错误,如果有人在这种情况下帮助我处理这个错误,我将不胜感激
File 'c:/Program Files/Microsoft VS Code/resources/app/extensions/node_modules/typescript/lib/lib.d.ts' not found.
The file is in the program because:
Default library for target 'es5'
Run Code Online (Sandbox Code Playgroud) Typescript 编译器对可选类属性的处理似乎已从 更改es2021
为es2022
。
class A {
a?: string
b?: string
constructor() {
this.b = 'asd'
}
}
console.log(new A())
Run Code Online (Sandbox Code Playgroud)
与 tsconfig target=es2021
结果
A: {
"b": "asd"
}
Run Code Online (Sandbox Code Playgroud)
与 tsconfig target=es2022
结果
A: {
"a": undefined,
"b": "asd"
}
Run Code Online (Sandbox Code Playgroud)
我找不到有关此更改的任何文档。这真的是有意的行为吗?为什么?
通过更改 TS Config->Target可以轻松在 ts Playground中重现
tsconfig ×10
typescript ×5
angular ×3
angular-jest ×1
ckeditor ×1
es2022 ×1
eslint ×1
fal ×1
ivy ×1
jestjs ×1
package.json ×1
react-tsx ×1
reactjs ×1
ts-loader ×1
tsc ×1
typo3 ×1
typoscript ×1