我在运行 npx webpack 时遇到了这个错误
Version: webpack 3.12.0
Time: 57478ms
Asset Size Chunks Chunk Names
app.js 172 kB 0 [emitted] app
vendor.js 7.91 MB 1 [emitted] [big] vendor
app.js.map 256 kB 0 [emitted] app
vendor.js.map 9.28 MB 1 [emitted] vendor
[21] ./angular/service.ts 3.92 kB {0} [built]
[23] ./angular/Utility.ts 2.21 kB {0} [built]
[37] (webpack)/buildin/global.js 509 bytes {1} [built]
[42] ./angular/component/empty.ts 1.35 kB {0} [built]
[66] ./angular/api.ts 3.15 kB {0} [built]
[85] ./angular/modules/LoadComponentModule.ts 1.92 kB {0} [built]
[250] ./angular/bootstrap.ts 2.58 kB {0} [built]
[251] ./angular/env.json 325 bytes {0} [built]
[587] ./angular/ErrorCatcher.ts 2.57 kB {0} [built]
[588] ./angular/modules/MaterialModules.ts 2.4 kB {0} [built]
[589] ./angular/modules/AFModules.ts 1.17 kB {0} [built]
[594] ./angular/Pipes.ts 5.64 kB {0} [built]
[595] ./angular/component/layout.ts 2.52 kB {0} [built]
[601] ./angular/component/management/wrapper.ts 3.91 kB {0} [built]
[605] ./angular/component/project/project_list.ts 4.87 kB {0} [built]
+ 595 hidden modules
ERROR in ./angular/component/search.ts
[tsl] ERROR in D:\nodeapps\myproject\angular\component\search.ts(101,34)
TS2345: Argument of type 'string' is not assignable to parameter of type 'CollectionReference'.
ERROR in ./angular/component/search.ts
[tsl] ERROR in D:\nodeapps\myproject\angular\component\search.ts(102,26)
TS2345: Argument of type 'CollectionReference' is not assignable to parameter of type 'Query | CollectionReference'.
Type 'firebase.firestore.CollectionReference' is not assignable to type 'FirebaseFirestore.CollectionReference'.
Property 'offset' is missing in type 'CollectionReference'.
文件中的错误行是this.collectionPath和org:
this.ref = this.afs.collection(this.collectionPath, org=>{
var r = this.whereAll(org, this.requirementQuerys);
this.params.forEach(p=>{
r = this.whereAll(r, p.querys);
});
return this.orderBy ? r.orderBy(this.orderBy) : r;
});
这是我在 package.json 中的依赖项:
"dependencies": {
"firebase-admin": "^5.12.1",
"firebase-functions": "^1.0.4",
"firebase-tools": "^3.18.6"
},
"devDependencies": {
"@angular/animations": "^5.2.5",
"@angular/cdk": "^5.2.1",
"@angular/cli": "^1.6.8",
"@angular/common": "^5.2.5",
"@angular/compiler": "^5.2.5",
"@angular/core": "^5.2.5",
"@angular/forms": "^5.2.5",
"@angular/http": "^5.2.5",
"@angular/material": "^5.2.1",
"@angular/platform-browser": "^5.2.5",
"@angular/platform-browser-dynamic": "^5.2.5",
"@angular/router": "^5.2.5",
"@google-cloud/functions-emulator": "^1.0.0-beta.4",
"@types/hammerjs": "^2.0.35",
"ajv": "^6.0.0",
"angularfire2": "^5.0.0-rc.6",
"concurrently": "^3.5.1",
"es6-shim": "~0.35.3",
"exports-loader": "~0.7.0",
"expose-loader": "~0.7.4",
"firebase": "^5.0.4",
"glob": "^7.1.2",
"hammerjs": "^2.0.8",
"http-server": "^0.11.1",
"imports-loader": "~0.7.1",
"node-sass": "^4.7.2",
"reflect-metadata": "~0.1.12",
"rxjs": "^5.5.6",
"ts-loader": "^3.5.0",
"typescript": "^2.7.1",
"webpack": "^3.11.0",
"webpack-dev-server": "^2.11.1",
"webpack-sources": "^1.1.0",
"zone.js": "~0.8.20"
},
这是我的webpack.config.js
require('./html_style');
const path = require('path');
const webpack = require('webpack');
const CommonsChunkPlugin = webpack.optimize.CommonsChunkPlugin;
const isVendor = function(module){return module.context && module.context.indexOf("node_modules") !== -1;};
module.exports = {
devtool: 'source-map',
watch: false,
entry: {
'app': './angular/bootstrap.ts'
},
output: {
filename: '[name].js',
path: path.resolve('./public/angular')
},
resolve: {
extensions: ['.ts', '.tsx', '.js']
},
module: {
exprContextCritical: false,
loaders: [
{ test: /\.ts?$/, exclude: /node_modules/, loader: 'ts-loader' }
]
},
plugins: [
new CommonsChunkPlugin({name: 'vendor', minChunks: isVendor})
]
}
我一直在谷歌搜索,但没有运气。任何的想法?我的平台是 Windows。我的node版本是10.9.0,npm版本是6.4.0。
最佳答案
你的问题有点类似于https://github.com/angular/angularfire2/issues/1467 .当您的 angularfire2 和 firebase 库版本不匹配时,就会发生这种情况。您的问题的解决方案是使用强类型。我已经修改了您的代码,因此您将有一个如何解决问题的示例:
import { AngularFirestore, Query, QueryFn } from 'angularfire2/firestore';
let query: QueryFn = org => {
let r: Query = this.whereAll(org, this.requirementQuerys);
this.params.forEach(p => {
r = this.whereAll(r, p.querys);
});
return this.orderBy ? r.orderBy(this.orderBy) : r;
};
this.ref = this.afs.collection(this.collectionPath, query);
以防万一你仍然有问题我使用了 "angularfire2": "^5.0.0-rc.12" 和 "firebase": "^5.4.0"。将来查看 angularfire2 github 问题以解释如果在下一次更新依赖项后您的项目无法运行,哪些版本是兼容的。
关于javascript - 类型 [type] 的参数不可分配给类型 [type] 的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52146905/
我在我的项目中添加了一个系统来重置用户密码并通过电子邮件将密码发送给他,以防他忘记密码。昨天它运行良好(当我实现它时)。当我今天尝试启动服务器时,出现以下错误。=>BootingWEBrick=>Rails3.2.1applicationstartingindevelopmentonhttp://0.0.0.0:3000=>Callwith-dtodetach=>Ctrl-CtoshutdownserverExiting/Users/vinayshenoy/.rvm/gems/ruby-1.9.3-p0/gems/actionmailer-3.2.1/lib/action_mailer
exe应该在我打开页面时运行。异步进程需要运行。有什么方法可以在ruby中使用两个参数异步运行exe吗?我已经尝试过ruby命令-system()、exec()但它正在等待过程完成。我需要用参数启动exe,无需等待进程完成是否有任何rubygems会支持我的问题? 最佳答案 您可以使用Process.spawn和Process.wait2:pid=Process.spawn'your.exe','--option'#Later...pid,status=Process.wait2pid您的程序将作为解释器的子进程执行。除
我有一些Ruby代码,如下所示:Something.createdo|x|x.foo=barend我想编写一个测试,它使用double代替block参数x,这样我就可以调用:x_double.should_receive(:foo).with("whatever").这可能吗? 最佳答案 specify'something'dox=doublex.should_receive(:foo=).with("whatever")Something.should_receive(:create).and_yield(x)#callthere
我正在为一个项目制作一个简单的shell,我希望像在Bash中一样解析参数字符串。foobar"helloworld"fooz应该变成:["foo","bar","helloworld","fooz"]等等。到目前为止,我一直在使用CSV::parse_line,将列分隔符设置为""和.compact输出。问题是我现在必须选择是要支持单引号还是双引号。CSV不支持超过一个分隔符。Python有一个名为shlex的模块:>>>shlex.split("Test'helloworld'foo")['Test','helloworld','foo']>>>shlex.split('Test"
我可以得到Infinity和NaNn=9.0/0#=>Infinityn.class#=>Floatm=0/0.0#=>NaNm.class#=>Float但是当我想直接访问Infinity或NaN时:Infinity#=>uninitializedconstantInfinity(NameError)NaN#=>uninitializedconstantNaN(NameError)什么是Infinity和NaN?它们是对象、关键字还是其他东西? 最佳答案 您看到打印为Infinity和NaN的只是Float类的两个特殊实例的字符串
我不确定传递给方法的对象的类型是否正确。我可能会将一个字符串传递给一个只能处理整数的函数。某种运行时保证怎么样?我看不到比以下更好的选择:defsomeFixNumMangler(input)raise"wrongtype:integerrequired"unlessinput.class==FixNumother_stuffend有更好的选择吗? 最佳答案 使用Kernel#Integer在使用之前转换输入的方法。当无法以任何合理的方式将输入转换为整数时,它将引发ArgumentError。defmy_method(number)
两者都可以defsetup(options={})options.reverse_merge:size=>25,:velocity=>10end和defsetup(options={}){:size=>25,:velocity=>10}.merge(options)end在方法的参数中分配默认值。问题是:哪个更好?您更愿意使用哪一个?在性能、代码可读性或其他方面有什么不同吗?编辑:我无意中添加了bang(!)...并不是要询问nobang方法与bang方法之间的区别 最佳答案 我倾向于使用reverse_merge方法:option
我有一个只接受一个参数的方法:defmy_method(number)end如果使用number调用方法,我该如何引发错误??通常,我如何定义方法参数的条件?比如我想在调用的时候报错:my_method(1) 最佳答案 您可以添加guard在函数的开头,如果参数无效则引发异常。例如:defmy_method(number)failArgumentError,"Inputshouldbegreaterthanorequalto2"ifnumbereputse.messageend#=>Inputshouldbegreaterthano
有时我需要处理键/值数据。我不喜欢使用数组,因为它们在大小上没有限制(很容易不小心添加超过2个项目,而且您最终需要稍后验证大小)。此外,0和1的索引变成了魔数(MagicNumber),并且在传达含义方面做得很差(“当我说0时,我的意思是head...”)。散列也不合适,因为可能会不小心添加额外的条目。我写了下面的类来解决这个问题:classPairattr_accessor:head,:taildefinitialize(h,t)@head,@tail=h,tendend它工作得很好并且解决了问题,但我很想知道:Ruby标准库是否已经带有这样一个类? 最佳
我正在尝试解析一个CSV文件并使用SQL命令自动为其创建一个表。CSV中的第一行给出了列标题。但我需要推断每个列的类型。Ruby中是否有任何函数可以找到每个字段中内容的类型。例如,CSV行:"12012","Test","1233.22","12:21:22","10/10/2009"应该产生像这样的类型['integer','string','float','time','date']谢谢! 最佳答案 require'time'defto_something(str)if(num=Integer(str)rescueFloat(s