Skip to content

Commit 7409c73

Browse files
revert: manually remove changes introduced in #234
1 parent 0fe3d9e commit 7409c73

File tree

3 files changed

+43
-15
lines changed

3 files changed

+43
-15
lines changed

src/TransformOperationExecutor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ export class TransformOperationExecutor {
225225
if (newValue.constructor.prototype) {
226226
const descriptor = Object.getOwnPropertyDescriptor(newValue.constructor.prototype, newValueKey);
227227
if ((this.transformationType === TransformationType.PLAIN_TO_CLASS || this.transformationType === TransformationType.CLASS_TO_CLASS)
228-
&& ((descriptor && !descriptor.writable) || newValue[newValueKey] instanceof Function)) // || TransformationType === TransformationType.CLASS_TO_CLASS
228+
&& ((descriptor && !descriptor.set) || newValue[newValueKey] instanceof Function)) // || TransformationType === TransformationType.CLASS_TO_CLASS
229229
continue;
230230
}
231231

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// import { expect } from "chai";
2+
3+
// import { plainToClass } from "../../src";
4+
5+
// describe("Prototype inheritance", () => {
6+
7+
// // https://github.com/typestack/class-transformer/issues/233
8+
// it("should set value if property has default value in prototype chain.", () => {
9+
// class TestObject {
10+
// normalProp: string = "Hello!";
11+
// prototypedProp: string;
12+
// }
13+
14+
// TestObject.prototype.prototypedProp = "I'm a BUG!";
15+
16+
// const payload = {
17+
// normalProp: "Goodbye!",
18+
// prototypedProp: "Goodbye!"
19+
// };
20+
21+
// const result = plainToClass(TestObject, payload);
22+
23+
// expect(result).to.eql({
24+
// normalProp: "Goodbye!",
25+
// prototypedProp: "Goodbye!"
26+
// });
27+
// });
28+
// });

test/functional/serialization-deserialization.spec.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -129,24 +129,24 @@ describe("serialization and deserialization objects", () => {
129129

130130
});
131131

132-
it("should overwrite default properties defined in prototype", () => {
133-
class TestObject {
134-
normalProp: string = "Hello!";
135-
prototypedProp: string;
136-
}
132+
// it("should overwrite default properties defined in prototype", () => {
133+
// class TestObject {
134+
// normalProp: string = "Hello!";
135+
// prototypedProp: string;
136+
// }
137137

138-
TestObject.prototype.prototypedProp = "I'm a BUG!";
138+
// TestObject.prototype.prototypedProp = "I'm a BUG!";
139139

140140

141-
const payload = {
142-
normalProp: "Goodbye!",
143-
prototypedProp: "Goodbye!"
144-
};
141+
// const payload = {
142+
// normalProp: "Goodbye!",
143+
// prototypedProp: "Goodbye!"
144+
// };
145145

146-
const result = deserialize(TestObject, JSON.stringify(payload));
146+
// const result = deserialize(TestObject, JSON.stringify(payload));
147147

148-
result.normalProp.should.be.eql("Goodbye!");
149-
result.prototypedProp.should.be.eql("Goodbye!");
150-
});
148+
// result.normalProp.should.be.eql("Goodbye!");
149+
// result.prototypedProp.should.be.eql("Goodbye!");
150+
// });
151151

152152
});

0 commit comments

Comments
 (0)