You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using TypeGen to generate TypeScript models from C# classes, the configuration and generation process is unexpectedly producing files such as i-collection.ts and i-enumerable.ts. These files are not required and contain invalid TypeScript code. The desired outcome is to generate only the models from the specified namespaces.
Environment
.NET Version: 8
TypeGen Version: 5.0.1
tgconfig.json Configuration
"outputPath": "C:/backapi", // Output path for generated files, relative to the project folder
"fileNameConverters": ["PascalCaseToKebabCaseConverter"], // Converter chain used for converting C# type names to TypeScript file names
"projectOutputFolder": "bin", // The project’s output folder
"typeNameConverters": [],
"tabLength": 2,
"singleQuotes": true,
"clearOutputDirectory": true,
"externalAssemblyPaths": ["./bin"],
"createIndexFile": false,
"enumStringInitializersConverters": ["PascalCaseToCamelCaseConverter"],
"generationSpecs": ["ApiModelsGenerationSpec"],
"customTypeMappings": { "Microsoft.AspNetCore.Http.IFormFile": "File" },
"explicitPublicAccessor": true,
"typeBlacklist": [
"IEnumerable",
"IEntityDto",
"IHasExtraProperties",
"ICollection",
"KeyValuePair",
"IDictionary",
"IReadOnlyCollection",
"IDeserializationCallback"
] // Types that should not be generated
}
* This is a TypeGen auto-generated file.
* Any changes made to this file can be lost when this file is regenerated.
*/
import { IEnumerable } from './i-enumerable';
export interface T[] extends T[] {
count: number;
isReadOnly: boolean;
}
i-enumerable.ts
* This is a TypeGen auto-generated file.
* Any changes made to this file can be lost when this file is regenerated.
*/
export interface T[] {
}
Expected Output
Only the models from the specified namespaces should be generated into TypeScript files, without generating any interfaces for collections like IEnumerable or ICollection.
Ensure IEnumerable and ICollection are blacklisted correctly in tgconfig.json.
Modify ApiModelsGenerationSpec to avoid processing any types related to collections.
Additional Notes
The issue might be related to default behavior or misconfiguration.
Custom mappings and blacklists should theoretically prevent these files from being generated.
Request
Please advise on how to configure TypeGen properly to avoid generating unnecessary files like i-collection.ts and i-enumerable.ts. Any guidance on correcting the configuration or updating the TypeGen tool itself would be appreciated.
The text was updated successfully, but these errors were encountered:
Description
When using TypeGen to generate TypeScript models from C# classes, the configuration and generation process is unexpectedly producing files such as
i-collection.ts
andi-enumerable.ts
. These files are not required and contain invalid TypeScript code. The desired outcome is to generate only the models from the specified namespaces.Environment
tgconfig.json
ConfigurationApiModelsGenerationSpec.cs
Output (Unwanted)
i-collection.ts
i-enumerable.ts
Expected Output
Only the models from the specified namespaces should be generated into TypeScript files, without generating any interfaces for collections like
IEnumerable
orICollection
.Steps to Reproduce
Set up a .NET 8 project.
Add TypeGen 5.0.1 as a package.
Configure
tgconfig.json
as shown above.Implement
ApiModelsGenerationSpec
as shown above.Run the TypeGen generation command:
typegen generate -p "path/to/project" -c "path/to/tgconfig.json"
Proposed Solution
IEnumerable
andICollection
are blacklisted correctly intgconfig.json
.ApiModelsGenerationSpec
to avoid processing any types related to collections.Additional Notes
Request
Please advise on how to configure TypeGen properly to avoid generating unnecessary files like
i-collection.ts
andi-enumerable.ts
. Any guidance on correcting the configuration or updating the TypeGen tool itself would be appreciated.The text was updated successfully, but these errors were encountered: