角动态形式项目迁移 - '输入'没有初始化器,也没有构造函数,Type T |的另一个错误不明确的

发布于 2025-01-27 01:18:20 字数 1246 浏览 4 评论 0原文

角动态形式项目迁移 - 类型误差| ”

我一直在寻找一个基于JSON数据集构建角度形式的示例项目,并找到了此项目 https://github.com/dkreider/advanced-dynamic-angular-form

一切都可以在我本地机器上为高级dynamic-angular-form项目构建和正常工作。认为我会将代码迁移到一个入门项目中,然后可以更好地了解正在发生的事情。创建一个新项目并迁移代码之后,我会在类文件form-field.ts中收到一个错误。

错误:src/app/model/form -field.ts:27:5-错误ts2322:键入't |未定义的“不能分配为't'。 可以用任意类型实例化的“ t”,该类型可能与't |无关不明确的'。 线:27 this.value = options.value;

直接链接到GitHub项目中的文件 https:https:// github。 COM/DKREIDER/ADVANDACT-DYNAMIC-ANGULAN-FORM/BLOB/MASTER/SRC/APP/FORM-FIEL.TS

我的想法是,它应该在我的新项目中起作用而无需更改任何代码。它必须是一些项目配置设置或编译器选项吗? 我已经比较了angular.json,tsconfig.json,两个项目之间的包装。

这是下载我的入门项目的链接, formtest 。并直接链接指向 form form-fields.js 在我的格式测试项目中,我不禁会觉得我缺少一些基本的东西。

感谢您的任何帮助或正确的方向。

Angular dynamic forms project migration - error of Type T | undefined

I've been looking for an example project for building angular forms based on JSON datasets and found this project https://github.com/dkreider/advanced-dynamic-angular-form

Everything builds and works correctly for advanced-dynamic-angular-form project on my local machine. Figured I would migrate the code into a starter project and in doing that get a better understanding of what is happening. After creating a new project and migrating the code over I receive one error in a class file, form-field.ts.

Error: src/app/model/form-field.ts:27:5 - error TS2322: Type 'T | undefined' is not assignable to type 'T'.
'T' could be instantiated with an arbitrary type which could be unrelated to 'T | undefined'.
Line: 27 this.value = options.value;

Direct link to file in github project
https://github.com/dkreider/advanced-dynamic-angular-form/blob/master/src/app/form-field.ts

My thinking is that it should work in my new project without having to change any code. It must be some project config setting or compiler options?
I've compared the angular.json, tsconfig.json, package.json between the two projects and can't see any real diffences.

Here is a link to download my starter project, formTest. And a direct link to form-fields.js in my formTest project Can't help but feel like I'm missing something basic.

Thanks for any help or a point in the right direction.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

江南月 2025-02-03 01:18:21

好的,所以tsconfig.json中的编译器选项,“严格”:true。在我发现项目之间的这种配置差异之后,对Angular的严格编译器选项进行了一些搜索,并且找到了这个

删除了“严格”​​:True,并在我的tsconfig.js中添加了每个严格选项。在这种情况下,“ Stricknullcheck”:True导致我的形式项目失败。

Ok, so the compiler option in tsconfig.json, “strict”: true. After I found this config difference between the projects did some searching about angular’s strict compiler option and found this.

Removed “strict”:true and added each strict option in my tsconfig.js. In this case, “strickNullCheck”:true was causing my formsTest project to fail.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文