Skip to content

fix(core): allow null for BrowserView.ptr type null assignment#350

Open
AhmedNAgy25 wants to merge 1 commit intoblackboardsh:mainfrom
AhmedNAgy25:fix/browserview-null-pointer-type
Open

fix(core): allow null for BrowserView.ptr type null assignment#350
AhmedNAgy25 wants to merge 1 commit intoblackboardsh:mainfrom
AhmedNAgy25:fix/browserview-null-pointer-type

Conversation

@AhmedNAgy25
Copy link
Copy Markdown

What

Fixes a TypeScript type safety issue in BrowserView by properly allowing null values for the ptr property.

  • Changed ptr from Pointer! (non-null assertion) to Pointer | null = null
  • Removed null as any type hack in the remove() method

Why

The ptr property represents a native pointer that becomes invalid after remove() is called. The previous code set it to null but the type didn't reflect this, requiring a type cast hack (as any) to work around TypeScript.

This fix:

  • Makes the types accurately represent the runtime behavior
  • Removes the type hack for cleaner code
  • Prevents potential runtime errors from improper null handling

- Change ptr from 'Pointer!' to 'Pointer | null = null'
- Remove 'as any' type hack when setting ptr to null in remove()
- Improves TypeScript type safety
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.

1 participant