This repository contains code to reproduce benjamn/recast issue #1012
recast
with recast/parser/typescript
can remove definite assignment assertions for class properties by setting ClassProperty.definite = false
(originally true
)
// Before
class A {
foo!: string;
}
// After
class A {
foo: string;
}
but cannot add definite assignment assertions for class properties by setting ClassProperty.definite = true
(originally undefined
)
// Before
class A {
foo: string;
}
// After
class A {
foo: string;
}
// should be `foo!: string;`
-
Clone this repo
-
Run
yarn install
-
Run
yarn run test
-
Test fails with the following error:
FAIL src/index.test.js ✓ should remove class property definite assignment assertion for "foo" (20 ms) ✕ should add class property definite assignment assertion for "foo (5 ms) ● should add class property definite assignment assertion for "foo expect(received).toBe(expected) // Object.is equality - Expected - 1 + Received + 1 ↵ class A { - foo!: string; + foo: string; bar: number; } 36 | targetIdentifierName: "foo", 37 | }); > 38 | expect(patched).toBe(expected); | ^ 39 | }); 40 | at Object.<anonymous> (src/index.test.js:38:19)