Skip to content

feat(core): allow signal() to be called without an initial value#68743

Open
arturovt wants to merge 1 commit into
angular:mainfrom
arturovt:feat/core_64118
Open

feat(core): allow signal() to be called without an initial value#68743
arturovt wants to merge 1 commit into
angular:mainfrom
arturovt:feat/core_64118

Conversation

@arturovt
Copy link
Copy Markdown
Contributor

Adds a no-argument overload to signal() so undefined is inferred when no initial value is provided, matching the behavior of the input() API.

// before
name = signal<string | undefined>(undefined);

// after — `undefined` is inferred automatically
name = signal<string>();

Closes #64118

@angular-robot angular-robot Bot added detected: feature PR contains a feature commit area: core Issues related to the framework runtime labels May 15, 2026
@ngbot ngbot Bot added this to the Backlog milestone May 15, 2026
@arturovt arturovt marked this pull request as ready for review May 15, 2026 14:53
@pullapprove pullapprove Bot requested a review from JeanMeche May 15, 2026 14:53
@JeanMeche JeanMeche added the target: minor This PR is targeted for the next minor release label May 18, 2026
explicitTypeWithValue = signal<string>('hello');

/** string */
withEqualOption = signal('hello', {equal: (a, b) => a === b});
Copy link
Copy Markdown
Member

@JeanMeche JeanMeche May 18, 2026

Choose a reason for hiding this comment

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

Can we ensure in the test that signal<number>('1'); still errors.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Alright, I’ll add it

@arturovt arturovt requested a review from JeanMeche May 18, 2026 19:22
Adds a no-argument overload to `signal()` so `undefined` is inferred when no initial value is provided, matching the behavior of the `input()` API.

```ts
// before
name = signal<string | undefined>(undefined);

// after — `undefined` is inferred automatically
name = signal<string>();
```

Closes angular#64118
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Issues related to the framework runtime detected: feature PR contains a feature commit target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

support Signal Function without argument (undefined implied)

2 participants