mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
Fixed crash in classFields transform related to broken bodyless constructors (#59280)
Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
This commit is contained in:
parent
09e47d0638
commit
ca4ef16c8f
@ -2416,11 +2416,11 @@ export function transformClassFields(context: TransformationContext): (x: Source
|
||||
factory.createBlock(
|
||||
setTextRange(
|
||||
factory.createNodeArray(statements),
|
||||
/*location*/ constructor ? constructor.body!.statements : node.members,
|
||||
/*location*/ constructor?.body?.statements ?? node.members,
|
||||
),
|
||||
multiLine,
|
||||
),
|
||||
/*location*/ constructor ? constructor.body : undefined,
|
||||
/*location*/ constructor?.body,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
classFieldsBrokenConstructorEmitNoCrash1.ts(3,3): error TS2390: Constructor implementation is missing.
|
||||
classFieldsBrokenConstructorEmitNoCrash1.ts(4,1): error TS1005: '(' expected.
|
||||
|
||||
|
||||
==== classFieldsBrokenConstructorEmitNoCrash1.ts (2 errors) ====
|
||||
class Test {
|
||||
prop = 42;
|
||||
constructor
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2390: Constructor implementation is missing.
|
||||
}
|
||||
~
|
||||
!!! error TS1005: '(' expected.
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
//// [tests/cases/compiler/classFieldsBrokenConstructorEmitNoCrash1.ts] ////
|
||||
|
||||
//// [classFieldsBrokenConstructorEmitNoCrash1.ts]
|
||||
class Test {
|
||||
prop = 42;
|
||||
constructor
|
||||
}
|
||||
|
||||
|
||||
//// [classFieldsBrokenConstructorEmitNoCrash1.js]
|
||||
"use strict";
|
||||
class Test {
|
||||
constructor() {
|
||||
this.prop = 42;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
//// [tests/cases/compiler/classFieldsBrokenConstructorEmitNoCrash1.ts] ////
|
||||
|
||||
=== classFieldsBrokenConstructorEmitNoCrash1.ts ===
|
||||
class Test {
|
||||
>Test : Symbol(Test, Decl(classFieldsBrokenConstructorEmitNoCrash1.ts, 0, 0))
|
||||
|
||||
prop = 42;
|
||||
>prop : Symbol(Test.prop, Decl(classFieldsBrokenConstructorEmitNoCrash1.ts, 0, 12))
|
||||
|
||||
constructor
|
||||
}
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
//// [tests/cases/compiler/classFieldsBrokenConstructorEmitNoCrash1.ts] ////
|
||||
|
||||
=== classFieldsBrokenConstructorEmitNoCrash1.ts ===
|
||||
class Test {
|
||||
>Test : Test
|
||||
> : ^^^^
|
||||
|
||||
prop = 42;
|
||||
>prop : number
|
||||
> : ^^^^^^
|
||||
>42 : 42
|
||||
> : ^^
|
||||
|
||||
constructor
|
||||
}
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
// @strict: true
|
||||
// @useDefineForClassFields: false
|
||||
// @target: es2021
|
||||
|
||||
class Test {
|
||||
prop = 42;
|
||||
constructor
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user