Skip to content
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

fix: negative number #566

Merged
merged 1 commit into from
Jun 11, 2024
Merged

fix: negative number #566

merged 1 commit into from
Jun 11, 2024

Conversation

maximebiloe
Copy link
Contributor

On our project we wanted to migrate to Typescript 5.4 but we encountered the following issue

Error: Debug Failure. False expression: Negative numbers should be created in combination with createPrefixUnaryExpression
    at Object.createNumericLiteral (node_modules/typescript/lib/typescript.js:21097:13)
    at Object.buildNumericLiteralTypeNode (node_modules/@anttiviljami/dtsgenerator/dist/core/astBuilder.js:56:56)
    at DtsGenerator.generateLiteralTypeNode (node_modules/@anttiviljami/dtsgenerator/dist/core/dtsGenerator.js:312:28)
    at node_modules/@anttiviljami/dtsgenerator/dist/core/dtsGenerator.js:279:29
    at Array.map (<anonymous>)
    at Object.buildUnionTypeNode (node_modules/@anttiviljami/dtsgenerator/dist/core/astBuilder.js:124:55)
    at DtsGenerator.generateLiteralTypeProperty (node_modules/@anttiviljami/dtsgenerator/dist/core/dtsGenerator.js:278:24)
    at DtsGenerator.generateTypeProperty (node_modules/@anttiviljami/dtsgenerator/dist/core/dtsGenerator.js:273:21)
    at DtsGenerator.generateProperties (node_modules/@anttiviljami/dtsgenerator/dist/core/dtsGenerator.js:244:84)
    at DtsGenerator.generateDeclareType (node_modules/@anttiviljami/dtsgenerator/dist/core/dtsGenerator.js:218:34)

So here is a PR to fix it.
To do it, I've locally bumped the Typescript version used to 5.4.5, created the test case and fixed the issue to use the right method.
I didn't want to upgrade the Typescript version in your package.json as I didn't know if you want to run further tests to declare your package compatible. If you want me to do it, let me know and I'll push an extra commit

@coveralls
Copy link

Coverage Status

coverage: 90.991% (+0.02%) from 90.976%
when pulling 8cbcca6 on maximebiloe:fix-negative-number
into 6fa1e9a on horiuchi:master.

2 similar comments
@coveralls
Copy link

Coverage Status

coverage: 90.991% (+0.02%) from 90.976%
when pulling 8cbcca6 on maximebiloe:fix-negative-number
into 6fa1e9a on horiuchi:master.

@coveralls
Copy link

Coverage Status

coverage: 90.991% (+0.02%) from 90.976%
when pulling 8cbcca6 on maximebiloe:fix-negative-number
into 6fa1e9a on horiuchi:master.

@horiuchi horiuchi merged commit e0a64b5 into horiuchi:master Jun 11, 2024
3 checks passed
@horiuchi
Copy link
Owner

@maximebiloe Thank you for your contribution!

I will release a new version, and upgrade TypeScript later.

@horiuchi
Copy link
Owner

Released by v3.19.2

@maximebiloe maximebiloe deleted the fix-negative-number branch June 11, 2024 06:31
@maximebiloe
Copy link
Contributor Author

Thank you for the quick merge 🙏
But it's weird, on npm we were already on v3.19.3

@maximebiloe
Copy link
Contributor Author

Indeed, it seems there are several packages pointing to this GitHub repository

openapi-client-axios-typegen relies on the first one and you published a new version for the second one.
Could you also publish a new version there, please?

@horiuchi
Copy link
Owner

https://www.npmjs.com/package/@anttiviljami/dtsgenerator is not owned by me.
Probably forked by @anttiviljami. Please tell that guy directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants