Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
{{/hasImports}}
{{#discriminator}}
{{#discriminator.mappedModels}}
import { type {{modelName}}, {{modelName}}FromJSONTyped, {{modelName}}ToJSON, {{modelName}}ToJSONTyped } from './{{modelName}}{{importFileExtension}}';
import { type {{modelName}}, {{modelName}}FromJSON, {{modelName}}FromJSONTyped, {{modelName}}ToJSON, {{modelName}}ToJSONTyped } from './{{modelName}}{{importFileExtension}}';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: For discriminator parents whose mapped children are never referenced as property types (such as Animal.ts, where Cat/Dog only appear as subtypes), the newly added FromJSON import is unused. Consumers that compile generated code with noUnusedLocals enabled will now get a TS6133 error on the import, where previously FromJSON was not imported at all. This widens the pre-existing ToJSON unused-import situation to FromJSON across such models. Consider importing FromJSON only when the mapped model is also used as a property type, or documenting that consumers must not enable noUnusedLocals.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache, line 16:

<comment>For discriminator parents whose mapped children are never referenced as property types (such as Animal.ts, where Cat/Dog only appear as subtypes), the newly added `FromJSON` import is unused. Consumers that compile generated code with `noUnusedLocals` enabled will now get a TS6133 error on the import, where previously `FromJSON` was not imported at all. This widens the pre-existing `ToJSON` unused-import situation to `FromJSON` across such models. Consider importing `FromJSON` only when the mapped model is also used as a property type, or documenting that consumers must not enable `noUnusedLocals`.</comment>

<file context>
@@ -13,7 +13,7 @@ import {
 {{#discriminator}}
 {{#discriminator.mappedModels}}
-import { type {{modelName}}, {{modelName}}FromJSONTyped, {{modelName}}ToJSON, {{modelName}}ToJSONTyped } from './{{modelName}}{{importFileExtension}}';
+import { type {{modelName}}, {{modelName}}FromJSON, {{modelName}}FromJSONTyped, {{modelName}}ToJSON, {{modelName}}ToJSONTyped } from './{{modelName}}{{importFileExtension}}';
 {{/discriminator.mappedModels}}
 {{/discriminator}}
</file context>

{{/discriminator.mappedModels}}
{{/discriminator}}
{{>modelGenericInterfaces}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
TestObjectTypeToJSONTyped,
} from './TestObjectType';

import { type ExtendDto, ExtendDtoFromJSONTyped, ExtendDtoToJSON, ExtendDtoToJSONTyped } from './ExtendDto';
import { type ExtendDto, ExtendDtoFromJSON, ExtendDtoFromJSONTyped, ExtendDtoToJSON, ExtendDtoToJSONTyped } from './ExtendDto';
/**
*
* @export
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import {
BranchDtoToJSONTyped,
} from './BranchDto';

import { type InternalAuthenticatedUserDto, InternalAuthenticatedUserDtoFromJSONTyped, InternalAuthenticatedUserDtoToJSON, InternalAuthenticatedUserDtoToJSONTyped } from './InternalAuthenticatedUserDto';
import { type RemoteAuthenticatedUserDto, RemoteAuthenticatedUserDtoFromJSONTyped, RemoteAuthenticatedUserDtoToJSON, RemoteAuthenticatedUserDtoToJSONTyped } from './RemoteAuthenticatedUserDto';
import { type InternalAuthenticatedUserDto, InternalAuthenticatedUserDtoFromJSON, InternalAuthenticatedUserDtoFromJSONTyped, InternalAuthenticatedUserDtoToJSON, InternalAuthenticatedUserDtoToJSONTyped } from './InternalAuthenticatedUserDto';
import { type RemoteAuthenticatedUserDto, RemoteAuthenticatedUserDtoFromJSON, RemoteAuthenticatedUserDtoFromJSONTyped, RemoteAuthenticatedUserDtoToJSON, RemoteAuthenticatedUserDtoToJSONTyped } from './RemoteAuthenticatedUserDto';
/**
*
* @export
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
*/

import { mapValues } from '../runtime';
import { type Cat, CatFromJSONTyped, CatToJSON, CatToJSONTyped } from './Cat';
import { type Dog, DogFromJSONTyped, DogToJSON, DogToJSONTyped } from './Dog';
import { type Cat, CatFromJSON, CatFromJSONTyped, CatToJSON, CatToJSONTyped } from './Cat';
import { type Dog, DogFromJSON, DogFromJSONTyped, DogToJSON, DogToJSONTyped } from './Dog';
/**
*
* @export
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/

import { mapValues } from '../runtime';
import { type ChildWithNullable, ChildWithNullableFromJSONTyped, ChildWithNullableToJSON, ChildWithNullableToJSONTyped } from './ChildWithNullable';
import { type ChildWithNullable, ChildWithNullableFromJSON, ChildWithNullableFromJSONTyped, ChildWithNullableToJSON, ChildWithNullableToJSONTyped } from './ChildWithNullable';
/**
*
* @export
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
*/

import { mapValues } from '../runtime';
import { type Cat, CatFromJSONTyped, CatToJSON, CatToJSONTyped } from './Cat';
import { type Dog, DogFromJSONTyped, DogToJSON, DogToJSONTyped } from './Dog';
import { type Cat, CatFromJSON, CatFromJSONTyped, CatToJSON, CatToJSONTyped } from './Cat';
import { type Dog, DogFromJSON, DogFromJSONTyped, DogToJSON, DogToJSONTyped } from './Dog';
/**
*
* @export
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/

import { mapValues } from '../runtime';
import { type ChildWithNullable, ChildWithNullableFromJSONTyped, ChildWithNullableToJSON, ChildWithNullableToJSONTyped } from './ChildWithNullable';
import { type ChildWithNullable, ChildWithNullableFromJSON, ChildWithNullableFromJSONTyped, ChildWithNullableToJSON, ChildWithNullableToJSONTyped } from './ChildWithNullable';
/**
*
* @export
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
*/

import { mapValues } from '../runtime';
import { type Cat, CatFromJSONTyped, CatToJSON, CatToJSONTyped } from './Cat';
import { type Dog, DogFromJSONTyped, DogToJSON, DogToJSONTyped } from './Dog';
import { type Cat, CatFromJSON, CatFromJSONTyped, CatToJSON, CatToJSONTyped } from './Cat';
import { type Dog, DogFromJSON, DogFromJSONTyped, DogToJSON, DogToJSONTyped } from './Dog';
/**
*
* @export
Expand Down
Loading