question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug?: typescript fails to compile angular services, duplicate exports

See original GitHub issue

What 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.

  1. Using orval@6.7.0 or later, typescript fails to compile with a previously working schema.

  2. Using orval.config.ts

    output: {
       mode: 'tags-split',
       workspace: 'src/api/sample-api',
       target: './sample-api.ts',
       client: 'angular',
       ...
    }
    

    N.B angular client

  3. 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:closed
  • Created a year ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
anymaniaxcommented, Jul 11, 2022

Thanks will look into it

2reactions
maartencardinaelscommented, Jul 11, 2022

we found out that the culprit is here, returnTypesToWrite is not cleared in between generations and accumulating the previous ones

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found