bug?: typescript fails to compile angular services, duplicate exports
See original GitHub issueWhat are the steps to reproduce this issue?
Attempting to update a project from orval@6.3.0
to latest generated compile errors. Found last working version orval@6.6.4
.
-
Using
orval@6.7.0
or later, typescript fails to compile with a previously working schema. -
Using
orval.config.ts
output: { mode: 'tags-split', workspace: 'src/api/sample-api', target: './sample-api.ts', client: 'angular', ... }
N.B
angular
client -
Run
orval --config orval.config.ts
to build
What happens?
Duplicate exports in each generated *.service.ts
regardless of the the endpoints defined
-
In
a.service.ts
export type GetValuesAllClientResult = NonNullable<void>; export type PostValuesClientResult = NonNullable<void>; export type GetValuesClientResult = NonNullable<void>; export type PutValuesClientResult = NonNullable<void>; export type DeleteValuesClientResult = NonNullable<void>;
-
In
b.service.ts
export type GetValuesAllClientResult = NonNullable<void>; export type PostValuesClientResult = NonNullable<void>; export type GetValuesClientResult = NonNullable<void>; export type PutValuesClientResult = NonNullable<void>; export type DeleteValuesClientResult = NonNullable<void>;
What were you expecting to happen?
Compile successfully.
Any logs, error output, etc?
Typescript fails to compile with several similar errors. It appears orval
is exporting all
Error: src/api/sample-api/index.ts:3:1 - error TS2308: Module './debug/debug.service' has already exported a member named 'ValuesPutClientResult'. Consider explicitly re-exporting to resolve the ambiguity.
export * from './values/values.service';.
In this case, ./debug/debug.service
is just the first service generated.
Any other comments?
Compiles with orval@6.6.4
What versions are you using?
Operating System: Windows 11 Package Version: 6.7.1+ Browser Version: N/A
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Error while using typescript 3.8 export aliases #17231 - GitHub
In your project, the "module" compiler flag in tsconfig.json is configured as "esnext" . This means that the export is preserved as is,...
Read more >error TS2300: Duplicate identifier 'export=' - Stack Overflow
I ran across this same error message recently but with jquery, and adding typeRoots in tsconfig. json resolved it.
Read more >NG0301: Export not found! - Angular
For example, if the export not found is ngForm , we need to import FormsModule and declare it in the list of imports...
Read more >Upgrading from AngularJS to Angular
For applications that use a module loader, TypeScript imports and exports (which are really ECMAScript 2015 imports and exports) can be used to...
Read more >Creating libraries - Angular
Anything exported from this file is made public when your library is imported into an application. Use an NgModule to expose services and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks will look into it
we found out that the culprit is here,
returnTypesToWrite
is not cleared in between generations and accumulating the previous ones