Skip to content

chore: update currentSingleElement to be a union type that includes undefined #9640

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

SamMousa
Copy link
Contributor

The type for currentSingleElement suggests it is always set, but it is not.

@@ -4728,7 +4728,7 @@ export class SurveyModel extends SurveyElementCore
}
return res;
}
public get currentSingleElement(): IElement {
public get currentSingleElement(): IElement|undefined {
return !this.isShowingPreview ? this.currentSingleElementValue : undefined;
}
public set currentSingleElement(val: IElement) {
Copy link
Member

Choose a reason for hiding this comment

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

Angular give the compiling error:
error TS2380: The return type of a 'get' accessor must be assignable to its 'set' accessor type
Type 'undefined' is not assignable to type 'IElement'.

set currentSingleElement(val: IElement|undefined)

Copy link
Contributor Author

@SamMousa SamMousa Mar 25, 2025

Choose a reason for hiding this comment

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

https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-1.html#unrelated-types-for-getters-and-setters

Seems like a very old typescript version?

Edit: it's an ancient version of angular: https://angular.dev/reference/versions
I'd propose dropping all unsupported versions of Angular and updating to TS >= 5.2.

Holding back your whole code base to support frameworks that no longer receive support makes no sense.

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.

2 participants