https://github.com/sunft1996/rspack-issue-ts-demo
issue专用,用于描述rspack处理ts时发生的问题
https://github.com/sunft1996/rspack-issue-ts-demo
Last synced: 3 months ago
JSON representation
issue专用,用于描述rspack处理ts时发生的问题
- Host: GitHub
- URL: https://github.com/sunft1996/rspack-issue-ts-demo
- Owner: sunft1996
- Created: 2024-07-01T10:56:02.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-07-01T11:45:35.000Z (11 months ago)
- Last Synced: 2025-02-23T05:37:06.276Z (3 months ago)
- Language: JavaScript
- Size: 45.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 描述
issue专用,用于展示rspack处理ts/js时发生的问题
# 项目执行
```shell
$ npm run build
```## rspack打包前
```JS
// src/index.ts
const xhr = {
responseType: false,
responseText: "OK",
response: {}
}console.log(
( xhr.responseType || "text" ) !== "text" ||
typeof xhr.responseText !== "string" ?
{ binary: 1 } :
{ text: 2 }
)// 条件一 和 条件二 均为false,因此实际应该打印 { text: 2 }
```## 打包后
```JS
// dist/main.jsvar xhr = {
responseType: false,
responseText: "OK",
response: {}
};
console.log((xhr.responseType || "text") !== "text" || 0 ? { // 语句:`typeof xhr.responseText !== "string"` 被转为 0
binary: 1
} : 0) // 此处打印{ binary: 1 } 或 0,结果都不对;```