# How to prevent candid remove duplicated type

**URL:** <https://forum.dfinity.org/t/how-to-prevent-candid-remove-duplicated-type/56188>\
**Category:** Developers\
**Created:** [August 29, 2025, 6:21am UTC](https://forum.dfinity.org/t/how-to-prevent-candid-remove-duplicated-type/56188 "2025-08-29T06:21:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![baolongt](https://avatars.discourse-cdn.com/v4/letter/b/4491bb/32.png) [@baolongt](https://forum.dfinity.org/u/baolongt)\
**Post date:** [August 29, 2025, 6:21am UTC](https://forum.dfinity.org/t/how-to-prevent-candid-remove-duplicated-type/56188/1 "2025-08-29T06:21:42Z")

</div>

I have a issue that I have 3 enum in rust have similar value but it is different enities

```rust
pub enum IntentState { Created, Processing, Success, Fail }
pub enum ActionState { Created, Processing, Success, Fail }
pub enum TxState { Created, Processing, Success, Fail }

```

when I run extract-candid it will only generate IntentState - I assume candid will remove duplicate value and mapping to only one type

```auto
type IntentState = variant { Fail; Success; Processing; Created };

type ActionDto = record {
  ...
  state : IntentState; // this should be ActionState
};

type TxDto = record {
  ...
  state : IntentState; // this should be TxState
};

```

How to avoid this?

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [August 29, 2025, 7:12am UTC](https://forum.dfinity.org/t/how-to-prevent-candid-remove-duplicated-type/56188/2 "2025-08-29T07:12:19Z")

</div>

Candid uses structural typing, meaning that if two types have the same fields they are the same type to Candid, even if you call them differently.

`candid-extractor` just does its thing. If you want to have the different types listed, you need to write the .did file by hand, which I would recommend anyways.

---

<div class="post-metadata">

**Author:** ![peterparker](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@peterparker](https://forum.dfinity.org/u/peterparker)\
**Post date:** [August 29, 2025, 7:47am UTC](https://forum.dfinity.org/t/how-to-prevent-candid-remove-duplicated-type/56188/3 "2025-08-29T07:47:06Z")

</div>

Not a direct answer to your question but, looking at it from another way around, if the states are indeed similar, you can maybe approach it by having a common enum? This way by extension your DID file won’t reference a keyword that feels unrelated?

```auto
pub enum State { Created, Processing, Success, Fail }
pub type IntentState = State;
pub type ActionState = State;
pub type TxState = State;

```

Which would output:

```auto
type State = variant { Fail; Success; Processing; Created };

type ActionDto = record {
  ...
  state : State;
};

type TxDto = record {
  ...
  state : State;
};

```

Unless of course you really needs different enum, in that case never mind this post!
