Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Fix possibly-null type errors #4

Merged
merged 2 commits into from
Mar 10, 2017

Conversation

gpittarelli
Copy link
Contributor

When I do a fresh clone + make, after the npm install succeeds, I get these type errors:

src/PacketHandler/PacketEntities.ts(97,10): error TS2531: Object is possibly 'null'.
src/Parser/SendPropParser.ts(37,11): error TS2531: Object is possibly 'null'.

This PR fixes those errors

@@ -94,7 +94,7 @@ function handleEntity(entity: PacketEntity, match: Match) {
}
}
if (prop.definition.ownerTableName === 'm_iAmmo') {
if (prop.value > 0) {
if (prop.value && prop.value > 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The >0 shouldn't be needed since 0 is will evaluate to false

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made it more specific. The type issue is that prop.value can be null there, so checking prop.value > 0 is throwing error TS2531: Object is possibly 'null'

@icewind1991 icewind1991 merged commit d341363 into demostf:master Mar 10, 2017
@icewind1991
Copy link
Collaborator

Thanks

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

Successfully merging this pull request may close these issues.

2 participants