Live Note

Remain optimistic

aab 包上传到 google play 时,会出现以下警告:

此 App Bundle 包含原生代码,您尚未上传调试符号文件。我们建议您上传调试符号文件,这样会便于针对崩溃和 ANR 问题进行分析和调试。

解决方法:首先需要安装项目对应的 ndk:

1
ndkVersion = "20.1.5948944"

SDK Tools 记得要开启 Show Package Details,然后下载对应版本的 NDK。
Android Studio -> SDK Manager -> SDK Tools -> NDK (Side by side) -> 20.1.5948944

然后在项目的 build.gradle 文件中配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
android {
//...
buildTypes {
release {
//...
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// 新增配置
ndk {
debugSymbolLevel 'FULL'
}
}
}
}

debugSymbolLevel 配置为 FULL,表示生成的符号文件包含所有调试信息。

最后,重新打包 aab 包,上传到 google play,即可解决此问题。

let 声明的变量在代码块内有效

1
2
3
4
5
6
7
var a [];
for (let i = 0; i < 10; i++) {
a[i] = function() {
console.log(i);
};
}
a[6](); //6

不存在变量提升

var 命令的变量可以在声明之前使用,值为 undefined

暂时性死区

在代码块内,使用 let 命令声明变量之前,该变量都是不可用的。TDZ(temporal dead zone)

1
2
3
4
5
var temp = 123
if (true) {
temp = "abc" //ReferenceError
let temp
}

有些死区是不易发现的

1
2
3
4
5
function bar(x = y, y = 2) {
//y is not defined
return [x, y]
}
let x = x //ReferenceError: x is not defined

不允许重复声明

1
2
3
4
function foo() {
var a
let a
}

直接使用 su 权限移除镜像的 quarantine 标志

1
sudo xattr -rd com.apple.quarantine /Applications/<application-name>

Introduction

1
2
3
4
5
6
7
8
9
interface A {
text: string
}

class B {
text: string
}

let a: A = new B() // no error

At least same member

1
2
3
4
5
6
7
8
9
10
11
interface A {
text: string
}

function foo(obj: { text: string }): string {
return obj.text
}

let obj = { text: "some text", num: 3 }
let a: A = obj // success
foo(obj) // success
Read more »

type="module"

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>

<script type="module">
// will not block the button
console.log(this) // undefined
console.log(import.meta.url) // the url of import file
</script>
<script>
// will block the button
console.log(this) // window
</script>

<script async type="module" src="http://example.com/test.js">
// will run immediate when the file is load
// example.com needs the Access-Control-Allow-Origin flag
import {sayHi} from 'sayHi' // this will get error because no path import in this module block.
</script>

<script nomodule>
alert("The Browser can not support the module import.")
</script>
</head>
<body>
<button>Button</button>
</body>
</html>