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

setInput with object parameter doesn't accept alias named inputs #691

Closed
kheos31 opened this issue Jan 27, 2025 · 2 comments
Closed

setInput with object parameter doesn't accept alias named inputs #691

kheos31 opened this issue Jan 27, 2025 · 2 comments

Comments

@kheos31
Copy link
Contributor

kheos31 commented Jan 27, 2025

Is this a regression?

Yes

Description

As discussed in following issue #648 , setInput has to accept alias named inputs.

This issue is currrently marked as closed because linked PR #652 provided a corresponding fix to the problem on the unit setInput, but not to the one taking an object as parameter.

This code currently failed to compile:

@Component({
  selector: 'app-root',
  standalone: true,
  template: ``,
  styles: ``,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class TestComponent {
  name = input<string>();
  inputWithAlias = input<string>('', { alias: 'input' });
}

describe('AppComponent', () => {
  let spectator: Spectator<TestComponent>;
  const createComponent = createComponentFactory(TestComponent);

  it('respect the alias input names', () => {
    spectator = createComponent({
      detectChanges: false,
    });

    spectator.setInput({
      name: 'test',
      input: 'testAlias', // <--- compilation failed here
    });
  });
});

I linked a reproduction link to see compilation error in the code.

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/stackblitz-starters-dqmjiled?file=src%2Ftest.spec.ts

Please provide the exception or error you saw

Object literal may only specify known properties, and 'input' does not exist in type 'InferInputSignals<TestComponent>'

Please provide the environment you discovered this bug in

Spectator 19.3.0 + Angular 19

Anything else?

No response

Do you want to create a pull request?

Yes

Copy link

stackblitz bot commented Jan 27, 2025

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@kheos31
Copy link
Contributor Author

kheos31 commented Jan 28, 2025

Thanks for your reactivity @NetanelBasal ! 👍

@kheos31 kheos31 closed this as completed Jan 28, 2025
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

No branches or pull requests

1 participant