运行我的本机代码时react-native run-android出现错误。它工作正常。但是在从 git 中获取新的 pullnpm ci并且在我运行之后然后收到这个错误。
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (30) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-29).
Dependency: androidx.core:core:1.7.0-alpha01.
AAR metadata file: C:\Users\gauraab\.gradle\caches\transforms-2\files-2.1\9e02d64f5889006a671d0a7165c73e72\core-1.7.0-alpha01\META-INF\com\android\build\gradle\aar-metadata.properties.
Run Code Online (Sandbox Code Playgroud) 我试图用IstanbulJS为我用TypeScript编写并经Cypress测试的代码生成代码覆盖率报告。但是事情变得不合时宜:

我专门针对此问题创建了一个git存储库 MCVE,因此您可以准确地再现我的情况:
git clone https://github.com/papb/cy-ts-istanbul-question
cd cy-ts-istanbul-question
npm install
npm test
# And then open the file `coverage/index.ts.html` to see the image above.
Run Code Online (Sandbox Code Playgroud)
如何解决?
我有一些用TypeScript编写的代码,这些代码可以通过rollup,rollup-plugin-typescript2和rollup-plugin-istanbul转换并捆绑到一个JavaScript(ES6)文件中。这非常完美,我在TypeScript中的源代码变成了一个文件,可以随<script>标签一起包含在浏览器中并使用。
其次,我使用cypress在HTML页面上运行测试,该页面包含上述转译的JS代码。cypress也可以完美地工作,赛普拉斯能够测试我最初用TypeScript编写的函数。
现在,我想为这些测试设置覆盖率报告。在赛普拉斯常见问题解答上,我们可以找到问题是否存在代码覆盖率?目前尚无答案(关于内置功能),但正在讨论中,这是将来要做的受欢迎的事情,并且实际上可以做到。
问题是:上面的人没有使用TypeScript。我是。因此,我需要做一些额外的步骤,这就是我目前遇到的问题。凭直觉,我认为这只是配置IstanbulJS以正确遵循源映射的问题,但是我找不到有关如何执行此操作的任何文档。我所能找到的每本有关TypeScript + IstanbulJS的指南都假设我正在使用Mocha,但我不是-我正在使用Cypress和来自TypeScript的转译源。
注意:我知道一般来说,进行赛普拉斯测试的通常“代码覆盖率”方法没有多大意义,但是在我的确切情况下,我认为确实如此,我已经考虑过了,请不要制作此框架挑战这个问题。
编辑:要清楚,在这里使用汇总并不是硬性要求。如果您有使用其他解决方案的解决方案,那也是完全可以接受的。正如标题所述,重要的是Cypress + TypeScript + IstanbulJS。
好奇我在Javascript中可以获得的最大字符串长度是什么,我今天在我的Firefox 43.0.1上测试了它,在Windows 7中运行.我能够构建一个长度很长的字符串2^28 - 1,但是当我尝试创建一个字符串时另外还有一个字符串,Firebug向我展示了"分配大小溢出"错误,这意味着该字符串必须小于256 MB.
这对所有浏览器,所有计算机,所有操作系统都是一样的,还是依赖于它?
我创建了以下代码片段以找出限制:
(function() {
strings = ["z"];
try {
while(true) {
strings.push(strings[strings.length - 1] + strings[strings.length - 1]);
}
} catch(err) {
var k = strings.length - 2;
while(k >= 0) {
try {
strings.push(strings[strings.length - 1] + strings[k]);
k--;
} catch(err) {}
}
console.log("The maximum string length is " + strings[strings.length - 1].length);
}
})();
Run Code Online (Sandbox Code Playgroud)
如果您运行的是其他浏览器/操作系统,我希望看到您的结果.我的结果是最大字符串长度是268435455.
PS:我四处寻找答案,但我发现的最新话题是2011年,所以我正在寻找更新的信息.
这次我真的很困惑Javascript:
var x = Array.prototype.concat.call;
typeof x; // function
x(); // Uncaught TypeError: x is not a function
Run Code Online (Sandbox Code Playgroud)
这到底是怎么回事?
如果有帮助,我也注意到:
x([1,2],[3,4]) 也不起作用
toString 也认为这是一个功能:
Object.prototype.toString.call(x); // "[object Function]"
Run Code Online (Sandbox Code Playgroud)这也发生在Array.prototype.concat.apply.
当它被强制作为表达式时,它也不起作用:
(0, Array.prototype.concat.call)([1,2],[3,4]); // Same TypeError
Run Code Online (Sandbox Code Playgroud)在Chrome和Node中测试过.
我想一个实用程序,我可以直接使用IsStrictlyAny<T>,它会解决的类型true,如果T是完全any和对false否则类型。我怎样才能做到这一点?
我的第一个想法:
type IsStrictlyAny<T> = any extends T ? true : false;
Run Code Online (Sandbox Code Playgroud)
结果:
IsStrictlyAny<any>:(true好!)IsStrictlyAny<unknown>:(true不好!-我想要false)IsStrictlyAny<string>:(boolean不好!-我想要false)虽然经历了sequelize文档,更具体的有关协会单证,我看到引导随便给出了读者的方法,例如setTasks(),addTask(),setProject(),,似乎是自动sequelize所有模型实例关于创建的关联创建.
我找不到什么方法可用的详细信息,以及他们是否与单一版本或多个版本创建的(因为既setTasks()和setProject(),例如),以及究竟是什么,他们希望,这样的参数.文档显然只是在示例中随便提及它们......
那么,当建立关联时,什么方法/ mixins sequelize会增加模型?什么是参数和返回值,即这些方法的文档是什么?或者,至少,我在哪里可以找到它们?
考虑类型FooBar1和FooBar2定义如下:
type Foo = { foo: string };
type Bar = { bar: number };
type FooBar1 = Foo & Bar;
type FooBar2 = { foo: string; bar: number };
Run Code Online (Sandbox Code Playgroud)
FooBar1和 和有FooBar2什么不一样?我的尝试/研究:
tsd-请参阅此处)tsd-请参阅此处){ foo } & { bar }自动进入{ foo, bar },而它倒塌了其他复杂类型简单的形式,如NonNullable<string | undefined>以string:// |------------------------------------------------------------|
// | let x: { |
// …Run Code Online (Sandbox Code Playgroud) 考虑我有一个元组元组:
type Example = [[3,5,7], [4,9], [0,1,10,9]];
Run Code Online (Sandbox Code Playgroud)
我想创建一个实用程序类型Flatten<T>,以便Flatten<Example>提供:
type FlatExample = Flatten<Example>;
// type FlatExample = [3,5,7,4,9,0,1,10,9];
Run Code Online (Sandbox Code Playgroud)
对于我的用例,您可以假设元组仅嵌套一层。元组可以有任何大小。
我怎样才能做到这一点?
Function和 和有(...args: any[]) => any什么区别?
有趣的是,我刚刚注意到Function不能分配给(...args: any[]) => any,但为什么呢?
declare let foo: Function;
declare let bar: (...args: any[]) => any;
bar = foo;
// ~~~
// ^^^
// Type 'Function' is not assignable to type '(...args: any[]) => any'.
// Type 'Function' provides no match for the signature '(...args: any[]): any'. (2322)
Run Code Online (Sandbox Code Playgroud)
考虑这个issue.py文件:
import subprocess
print('Calling subprocess...')
subprocess.run(['python', '--version'])
print('Subprocess is done!')
Run Code Online (Sandbox Code Playgroud)
python issue.py手动执行会产生我期望的结果:
Calling subprocess...
Python 3.9.0
Subprocess is done!
Run Code Online (Sandbox Code Playgroud)
但是,如果我在 Docker 容器中执行此操作,则会发生一些奇怪的事情:
$ docker run --rm -v $(pwd):/issue python:3.9.0 python /issue/issue.py
Python 3.9.0
Calling subprocess...
Subprocess is done!
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题,让 Docker 尊重正确的输出顺序?
笔记:
stderr,虽然上面的MCVE没有显示它。python直接使用图像,但在我的实际用例中,我有一个来自自定义 Dockerfile 的自定义图像,该文件使用FROM python.capture_output=True在subprocess.run调用中使用然后打印捕获的输出对我来说不是一个选项,因为我的真实用例调用了一个子进程,它会随着时间的推移将信息打印到stdout(与 不同python --version)并且我不能等待它完成之后才打印整个输出。javascript ×5
typescript ×5
types ×2
android ×1
associations ×1
cypress ×1
docker ×1
function ×1
istanbul ×1
memory ×1
orm ×1
prototype ×1
python ×1
react-native ×1
rollupjs ×1
sequelize.js ×1
stderr ×1
stdout ×1
string ×1
subprocess ×1
tuples ×1
typeerror ×1