TypeScript 在转换和解析过程中崩溃(来自Assert/调试失败)

gk7wooem  于 5个月前  发布在  TypeScript
关注(0)|答案(4)|浏览(92)

🔎 Search Terms

Debug Failure,modifierVisitor

🕗 Version & Regression Information

  • This is a crash
  • This changed between versions 5.2__ and _5.3(Both versions 4.7-5.2 and 5.2-5.4.5 reported Debug Failure errors, but the error information is different)
  • No response*

💻 Code

I did not use tsc to execute any ts programs, but instead used the command "node --max-old-space-size=10240 $(which tsc)" to increase the memory of node.js. When the version of tsc is between 5.3 and 5.4.5, the debugging error message is in “error message 1 "of "Actual behavior", and when the version of tsc is between 4.7 and 5.2, the debugging error message is in "error message 2" of "Actual behavior". I did not test versions before version 4.7 (The relevant version and configuration information are written in "Additional information about the issue")
(The relevant version and configuration information are written in "Additional information about the issue")

t2a7ltrp

t2a7ltrp1#

你能尝试缩小范围吗?如果不知道导致问题的源文件,几乎无法修复这个问题。

vuv7lop3

vuv7lop32#

是的,你可以尝试的一种方法是不断删除文件,直到找到罪魁祸首。然后当你将问题缩小到尽可能少的文件时,尽量删除尽可能多的代码行。

hpxqektj

hpxqektj3#

我已经筛选出了可能导致上述问题的ts文件,并在可能出错的文件中定位了代码行。
我在Ubuntu 22.04.3 LTS平台上修改了tsconfig.json,并使用了tsc测试程序的5.4.5版本。
在这个仓库中,我提供了配置文件、TS源文件和具体的错误信息:https://github.com/Roise-yue/tscFuzz

hgc7kmma

hgc7kmma4#

非常感谢你们找到这些@Roise-yue!我将这些文件复制到这个评论中,以便于跟踪 - 转换崩溃是由于在某些地方使用了accessor关键字:

// @target: esnext
// @noTypesAndSymbols: true

abstract class C1 {
    accessor accessor a: any;
    readonly accessor b: any;
    declare accessor c: any;
    accessor public d: any;
    accessor private e: any;
    accessor protected f: any;
    accessor abstract g: any;
    accessor static h: any;
    accessor i() {}
    accessor get j() { return false; }
    accessor set k(v: any) {}
    accessor constructor() {}
    accessor l?: any;
    accessor readonly m: any;
    accessor declare n: any;
}

class C2 extends C1 {
    accessor override g: any;
}

interface I1 {
    accessor a: number;
}

accessor class C3 {}
accessor interface I2 {}
accessor namespace N1 {}
accessor enum E1 {}   // Error location
accessor var V1: any;
accessor type T1 = never;
accessor function F1() {}
accessor import "x";
accessor import {} from "x";
accessor export { V1 };
accessor export default V1;
accessor import N2 = N1;

(Playground链接在这里)
另一个错误我还没有独立验证,但我将其粘贴在这里。

// @importHelpers: true
// @target: es5
// @module: commonjs
// @moduleResolution: classic
// @experimentalDecorators: true
// @emitDecoratorMetadata: true
// @filename: external.ts
export * from "./other";
export class A { }
export class B extends A { }

declare var dec: any;

@dec
class C {
    method(@dec x: number) {    // Error location
    }
}

const o = { a: 1 };
const y = { ...o };
const { ...x } = y;

// @filename: other.ts
export const x = 1;

// @filename: script.ts
class A { }
class B extends A { }

declare var dec: any;

@dec
class C {
    method(@dec x: number) {
    }
}

// @filename: tslib.d.ts
export {}

相关问题