升级到Angular 6后构建失败(Build failing after upgrading to Angular 6)
我刚刚将我的Angular 5项目升级到6.并且构建失败了:
node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker-service.d.ts(5,10)中的错误:错误TS2305:模块'“C:/ myapp / node_modules / rxjs / Observable”'没有导出成员'Observable'.node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(3,10):错误TS2305:模块'“C:/ myapp / node_modules / rxjs / Observable”'没有导出的成员'Observable'.node_modules / rxjs / Observable.d.ts(1,15):错误TS2307:找不到模块'rxjs-compat / Observable'。
关于如何解决这个问题的任何想法?
注意:
如果将
ng-bootstrap
添加到项目(甚至是新的Angular 6项目),则会出现此问题。I just upgraded my Angular 5 project to 6. And build is failing with:
ERROR in node_modules/@ng-bootstrap/ng-bootstrap/datepicker/datepicker-service.d.ts(5,10): error TS2305: Module '"C:/myapp/node_modules/rxjs/Observable"' has no exported member 'Observable'.node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts(3,10): error TS2305: Module '"C:/myapp/node_modules/rxjs/Observable"' has no exported member 'Observable'.node_modules/rxjs/Observable.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Observable'.
Any ideas on how to solve this?
NOTE:
This problem occurs if adding
ng-bootstrap
to the project (even a new Angular 6 project).
原文:https://stackoverflow.com/questions/50168357
最满意答案
你是对的:Coq中的类型类只是具有特殊管道和推理的记录(还有单方法类型类的特殊情况,但它不会以任何方式影响这个答案)。 因此,您选择类型类而不是“纯”依赖记录的唯一原因是受益于您使用它们得到的特殊推理:使用普通依赖记录进行推理并不是非常强大,并且不允许您省略很多信息。
作为示例,请考虑以下代码,该代码定义了一个monoid类型类,使用自然数进行实例化:
Class monoid A := Monoid { op : A -> A -> A; id : A; opA : forall x y z, op x (op y z) = op (op x y) z; idL : forall x, op id x = x; idR : forall x, op x id = x }. Require Import Arith. Instance nat_plus_monoid : monoid nat := {| op := plus; id := 0; opA := plus_assoc; idL := plus_O_n; idR := fun n => eq_sym (plus_n_O n) |}.
使用类型类推断,我们可以使用任何直接用于
nat
任何monoid的定义,而不提供类型类参数,例如Definition times_3 (n : nat) := op n (op n n).
但是,如果通过“
Record
和Definition
替换“Class
和Instance
将上述定义转换为常规记录,则相同的定义将失败:Toplevel input, characters 38-39: Error: In environment n : nat The term "n" has type "nat" while it is expected to have type "monoid ?11".
对类型类的唯一警告是实例推理引擎有时会有点丢失,导致出现难以理解的错误消息。 话虽这么说,但鉴于这种可能性甚至在那里都没有,它并不是真正的依赖记录。
You are right: type classes in Coq are just records with special plumbing and inference (there's also the special case of single-method type classes, but it doesn't really affect this answer in any way). Therefore, the only reason you would choose type classes over "pure" dependent records is to benefit from the special inference that you get with them: inference with plain dependent records is not very powerful and doesn't allow you to omit much information.
As an example, consider the following code, which defines a monoid type class, instantiating it with natural numbers:
Class monoid A := Monoid { op : A -> A -> A; id : A; opA : forall x y z, op x (op y z) = op (op x y) z; idL : forall x, op id x = x; idR : forall x, op x id = x }. Require Import Arith. Instance nat_plus_monoid : monoid nat := {| op := plus; id := 0; opA := plus_assoc; idL := plus_O_n; idR := fun n => eq_sym (plus_n_O n) |}.
Using type class inference, we can use any definitions that work for any monoid directly with
nat
, without supplying the type class argument, e.g.Definition times_3 (n : nat) := op n (op n n).
However, if you make the above definition into a regular record by replacing
Class
andInstance
byRecord
andDefinition
, the same definition fails:Toplevel input, characters 38-39: Error: In environment n : nat The term "n" has type "nat" while it is expected to have type "monoid ?11".
The only caveat with type classes is that the instance inference engine gets a bit lost sometimes, causing hard-to-understand error messages to appear. That being said, it's not really a disadvantage over dependent records, given that this possibility isn't even available there.
相关问答
更多-
斯卡拉Typeclasses(Scala Typeclasses)[2022-12-05]
你现在可以做的每件事都是 Str[Int].str(1) 要使用1.str你需要引入隐式转换。 你可以使用这种方法: implicit class StrOps[A](val self: A) extends AnyVal { def str(implicit S: Str[A]) = S.str(self) } 这使: scala> 1.str res2: String = 1 Everything you can do now is Str[Int].str(1) to use 1.st ... -
如何在ActiveRecord中删除具有相关记录的多个记录(How do I delete multiple records with dependent records in ActiveRecord)[2022-05-22]
class Foo < ActiveRecord::Base has_many :foo_bars, :dependent => :destroy end class FooBar < ActiveRecord::Base belongs_to :foo end 如果你的关系如上所述,以下代码将起作用 Foo.delete_all(["id in (?)", [3,4,5,6]]) 要不就 Foo.delete([3,4,5,6]) 删除 EDITED 从小我知道你的问题,我认为你有像下 ... -
:dependent =>:destroy会破坏不再依赖的记录(:dependent => :destroy destroys records that are no longer dependents)[2022-03-06]
猜测一下,我会在移动其他进程(并在销毁之前)尝试重新加载lp 。 实例变量可能包含对它认为仍属于它的进程的引用(即使它们不再这样做)。 At a guess, I'd try reloading the lp after moving the other processes (and before destroying it). The instance variable probably contains references to what it thinks are still processes t ... -
重写失败的原因是k在S显示为隐藏参数,因此通过重写您使目标输入错误的所有事件。 您可以使用Set Printing All来检查。 by rewrite {5}H3. 将关闭你的目标。 请注意,在mathcomp中不鼓励使用H1...Hn样式的命名目标。 你的缩进也不遵循math-comp风格,你可能想要使用exact:代替by apply: . 使用max_card也可以缩短您的证明: by rewrite -{8}(card_ord k) max_card. 要么 by rewrite -[k in ...
-
State , StateT和其他类似的类型来自transformers ,而MonadState类型类和其他类型类似于它来自mtl 。 注意前者是类型 ,而后者是类型类型 。 来自transformers的类型是Monad和MonadTrans实例。 你可以直接与他们合作,但有一些烦恼: 如果您将monad堆叠了几层,那么您必须在代码中加入大量调用才能访问各层的功能。 有时两种不同的类型提供相同的“界面”。 例如, RWST和ReaderT都提供类似读者的功能,如ask 。 在编写一个函数时,不得不承诺一 ...
-
你是对的:Coq中的类型类只是具有特殊管道和推理的记录(还有单方法类型类的特殊情况,但它不会以任何方式影响这个答案)。 因此,您选择类型类而不是“纯”依赖记录的唯一原因是受益于您使用它们得到的特殊推理:使用普通依赖记录进行推理并不是非常强大,并且不允许您省略很多信息。 作为示例,请考虑以下代码,该代码定义了一个monoid类型类,使用自然数进行实例化: Class monoid A := Monoid { op : A -> A -> A; id : A; opA : forall x y z, ...
-
问题是Forall_dec在标准库中被定义为不透明(也就是说,用Qed代替Defined )。 因此,Coq不知道使用wfdec是有效的。 您的问题的直接解决方案是重新定义Forall_dec以使其透明。 您可以通过打印Coq生成的证明术语并将其粘贴到源文件中来完成此操作。 我在这里添加了一个完整的解决方案。 不用说,这种方法使其本身变得臃肿,难以阅读,并且难以维护代码。 正如ejgallego在他的回答中指出的那样,在这种情况下,最好的办法是定义一个决定WF的布尔函数,并用它来代替WFDec 。 正如他所 ...
-
查找并销毁相关记录(Find and destroy dependent records)[2022-02-04]
最快的方法可能是在db控制台中执行它的目录,但是如果你有其他依赖关系和activerecord回调你需要被触发,你可以做类似的事情: Post.where("id in (select p.id from posts p left outer join users u on p.user_id = u.id where u.id is null)").destroy_all Fastest way would probably be to do it directory in the db console ... -
zltz与nltz 0具有相同的类型。 Check zltz. Check nltz 0. 使用2和[1; 2; 3] [1; 2; 3] [1; 2; 3]从另一个函数中,你可以使用lt_dec 。 Eval compute in match lt_dec 2 (length [1; 2; 3]) with | left pf => safe_nth 2 [1; 2; 3] pf | right _ => 0 end. 如果你提取lt_dec ,你会发现它在擦除证据后与lt_dec非常相似 ...
-
如何使用猫类型类?(How to use cats typeclasses?)[2022-03-25]
您正在导入Foldable[List]的实例两次:一次import cats.implicits._ ,一次import cats.instances.all._ 。 他们变得模棱两可。 查看源代码,您可以看到cats.instances.all是cats.instances.all的子集。 简化: package cats { package object instances { object all extends AllInstances } object implicits e ...