Skip to content

fix: remove <any> from enum declaration #16173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RobbyUitbeijerse
Copy link

Hi there!

Currently the enum values generated through the typescript-node generator are typed as . They get outputted like so:

export enum TestEnum {
    Something = <any> 'something'
}

But there seems to be no apparent reason as to why is being used. Note that the last change to this line was 5 years ago, so there might have been a perfectly understandable reason why this was put in there at the time

However, with modern Typescript this leads to issues, as it isn't able to infer the enum value. For example, the following code leads to issues:

export enum TestEnum {
    Something = <any> 'something'
}

const foo = 'something'

foo === TestEnum.Something 

Attached below is an illustration of what is going on:

Screenshot 2023-07-24 at 10 51 20

When the typing is removed, the enum gets processed correctly and string/enum comparison works as expected.

Screenshot 2023-07-24 at 10 53 51

Let me know if I'm missing something here. Please note that other typescript generators that I've checked don't have the type in place. (typescript-axios for example)

@RobbyUitbeijerse RobbyUitbeijerse changed the title chore: remove <any> from enum declaration fix: remove <any> from enum declaration Jul 24, 2023
@wing328
Copy link
Member

wing328 commented Aug 27, 2023

can you please follow step3 in the PR checklist to update the samples so that CIs can verify the change?

@TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @topce (2018/10) @akehir (2019/07) @petejohansonxo (2019/11) @amakhrov (2020/02) @davidgamero (2022/03) @mkusaka (2022/04)

@wing328 wing328 added this to the 7.0.1 milestone Aug 27, 2023
@wing328 wing328 modified the milestones: 7.0.1, 7.1.0 Sep 19, 2023
@wing328 wing328 modified the milestones: 7.1.0, 7.2.0 Nov 13, 2023
@wing328 wing328 modified the milestones: 7.2.0, 7.3.0 Dec 22, 2023
@wing328 wing328 modified the milestones: 7.3.0, 7.4.0 Feb 8, 2024
@wing328 wing328 modified the milestones: 7.4.0, 7.5.0 Mar 11, 2024
@wing328 wing328 modified the milestones: 7.5.0, 7.6.0 Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants