File tree Expand file tree Collapse file tree 4 files changed +29
-0
lines changed
Expand file tree Collapse file tree 4 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ import { Primitives } from "../src/Primitives" ;
12import { City } from "./City" ;
23import { Street } from "./Street" ;
34
45export class Address {
56 constructor ( readonly street : Street , readonly city : City ) { }
7+
8+ toPrimitives ( ) : Primitives < Address > {
9+ return {
10+ street : this . street . value ,
11+ city : this . city . value ,
12+ } ;
13+ }
614}
Original file line number Diff line number Diff line change 1+ import { Primitives } from "../src/Primitives" ;
12import { CourseId } from "./CourseId" ;
23
34export class Course {
45 constructor ( readonly courseId : CourseId ) { }
56
7+ toPrimitives ( ) : Primitives < Course > {
8+ return {
9+ courseId : this . courseId . value ,
10+ } ;
11+ }
12+
613 thisFunctionShouldNotBeIncludedInTheToPrimitives ( ) : boolean {
714 return true ;
815 }
Original file line number Diff line number Diff line change 1+ import { Primitives } from "../src/Primitives" ;
12import { CourseId } from "./CourseId" ;
23
34export class Learner {
45 constructor ( readonly enrolledCourses : CourseId [ ] ) { }
6+
7+ toPrimitives ( ) : Primitives < Learner > {
8+ return {
9+ enrolledCourses : this . enrolledCourses . map ( ( course ) => course . value ) ,
10+ } ;
11+ }
512}
Original file line number Diff line number Diff line change 1+ import { Primitives } from "../src/Primitives" ;
12import { Address } from "./Address" ;
23
34export class User {
45 constructor ( readonly address : Address ) { }
6+
7+ toPrimitives ( ) : Primitives < User > {
8+ return {
9+ address : this . address . toPrimitives ( ) ,
10+ } ;
11+ }
512}
You can’t perform that action at this time.
0 commit comments