Skip to content

Commit f6f8c62

Browse files
committed
ts: make resourceType check predicates more type strict.
1 parent b983ea4 commit f6f8c62

154 files changed

Lines changed: 156 additions & 154 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/typescript-r4/fhir-types/hl7-fhir-r4-core/Account.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ export interface Account extends DomainResource {
4646
type?: CodeableConcept;
4747
}
4848
export const isAccount = (resource: any): resource is Account => {
49-
return resource && resource.resourceType === "Account";
49+
return resource !== null && typeof resource === "object" && (resource as {resourceType: string}).resourceType === "Account";
5050
}

examples/typescript-r4/fhir-types/hl7-fhir-r4-core/ActivityDefinition.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,5 +127,5 @@ export interface ActivityDefinition extends DomainResource {
127127
_version?: Element;
128128
}
129129
export const isActivityDefinition = (resource: any): resource is ActivityDefinition => {
130-
return resource && resource.resourceType === "ActivityDefinition";
130+
return resource !== null && typeof resource === "object" && (resource as {resourceType: string}).resourceType === "ActivityDefinition";
131131
}

examples/typescript-r4/fhir-types/hl7-fhir-r4-core/AdverseEvent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,5 @@ export interface AdverseEvent extends DomainResource {
5555
suspectEntity?: AdverseEventSuspectEntity[];
5656
}
5757
export const isAdverseEvent = (resource: any): resource is AdverseEvent => {
58-
return resource && resource.resourceType === "AdverseEvent";
58+
return resource !== null && typeof resource === "object" && (resource as {resourceType: string}).resourceType === "AdverseEvent";
5959
}

examples/typescript-r4/fhir-types/hl7-fhir-r4-core/AllergyIntolerance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,5 @@ export interface AllergyIntolerance extends DomainResource {
6464
verificationStatus?: CodeableConcept;
6565
}
6666
export const isAllergyIntolerance = (resource: any): resource is AllergyIntolerance => {
67-
return resource && resource.resourceType === "AllergyIntolerance";
67+
return resource !== null && typeof resource === "object" && (resource as {resourceType: string}).resourceType === "AllergyIntolerance";
6868
}

examples/typescript-r4/fhir-types/hl7-fhir-r4-core/Appointment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,5 @@ export interface Appointment extends DomainResource {
6060
supportingInformation?: Reference<"Resource">[];
6161
}
6262
export const isAppointment = (resource: any): resource is Appointment => {
63-
return resource && resource.resourceType === "Appointment";
63+
return resource !== null && typeof resource === "object" && (resource as {resourceType: string}).resourceType === "Appointment";
6464
}

examples/typescript-r4/fhir-types/hl7-fhir-r4-core/AppointmentResponse.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ export interface AppointmentResponse extends DomainResource {
2929
_start?: Element;
3030
}
3131
export const isAppointmentResponse = (resource: any): resource is AppointmentResponse => {
32-
return resource && resource.resourceType === "AppointmentResponse";
32+
return resource !== null && typeof resource === "object" && (resource as {resourceType: string}).resourceType === "AppointmentResponse";
3333
}

examples/typescript-r4/fhir-types/hl7-fhir-r4-core/AuditEvent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,5 @@ export interface AuditEvent extends DomainResource {
7979
type: Coding;
8080
}
8181
export const isAuditEvent = (resource: any): resource is AuditEvent => {
82-
return resource && resource.resourceType === "AuditEvent";
82+
return resource !== null && typeof resource === "object" && (resource as {resourceType: string}).resourceType === "AuditEvent";
8383
}

examples/typescript-r4/fhir-types/hl7-fhir-r4-core/Basic.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ export interface Basic extends DomainResource {
2323
subject?: Reference<"Resource">;
2424
}
2525
export const isBasic = (resource: any): resource is Basic => {
26-
return resource && resource.resourceType === "Basic";
26+
return resource !== null && typeof resource === "object" && (resource as {resourceType: string}).resourceType === "Basic";
2727
}

examples/typescript-r4/fhir-types/hl7-fhir-r4-core/Binary.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ export interface Binary extends Resource {
1818
securityContext?: Reference<"Resource">;
1919
}
2020
export const isBinary = (resource: any): resource is Binary => {
21-
return resource && resource.resourceType === "Binary";
21+
return resource !== null && typeof resource === "object" && (resource as {resourceType: string}).resourceType === "Binary";
2222
}

examples/typescript-r4/fhir-types/hl7-fhir-r4-core/BiologicallyDerivedProduct.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,5 @@ export interface BiologicallyDerivedProduct extends DomainResource {
6363
storage?: BiologicallyDerivedProductStorage[];
6464
}
6565
export const isBiologicallyDerivedProduct = (resource: any): resource is BiologicallyDerivedProduct => {
66-
return resource && resource.resourceType === "BiologicallyDerivedProduct";
66+
return resource !== null && typeof resource === "object" && (resource as {resourceType: string}).resourceType === "BiologicallyDerivedProduct";
6767
}

0 commit comments

Comments
 (0)