Skip to content

Commit

Permalink
fix(NJsonSchema.CodeGeneration.TypeScript): for strict null checking,…
Browse files Browse the repository at this point in the history
… include explicit '| null' to return type of createInstance (#1287)
  • Loading branch information
rars authored Nov 26, 2020
1 parent 2ed102c commit 75e55c5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
{% endif -%}
}

static fromJS(data: any{% if HandleReferences %}, _mappings?: any{% endif %}): {{ ClassName }} {
static fromJS(data: any{% if HandleReferences %}, _mappings?: any{% endif %}): {{ ClassName }}{% if HandleReferences %} | null{% endif %} {
data = typeof data === 'object' ? data : {};
{% if HandleReferences -%}
{% if HasBaseDiscriminator -%}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
return json;
}

function createInstance<T>(data: any, mappings: any, type: any): T {
function createInstance<T>(data: any, mappings: any, type: any): T | null {
if (!mappings)
mappings = [];
if (!data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
}
}

static fromJS(data: any{% if HandleReferences %}, _mappings?: any{% endif %}): {{ ClassName }} {
static fromJS(data: any{% if HandleReferences %}, _mappings?: any{% endif %}): {{ ClassName }}{% if HandleReferences %} | null{% endif %} {
{% if HandleReferences -%}
{% if HasBaseDiscriminator -%}
{% for derivedClass in DerivedClasses -%}
Expand Down

0 comments on commit 75e55c5

Please sign in to comment.