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

Component arguments incorrectly typed as any #77

Open
wagenet opened this issue Mar 8, 2021 · 0 comments
Open

Component arguments incorrectly typed as any #77

wagenet opened this issue Mar 8, 2021 · 0 comments

Comments

@wagenet
Copy link
Contributor

wagenet commented Mar 8, 2021

// models/app.ts

import Model, { AsyncBelongsTo, belongsTo } from '@ember-data/model';
import User from 'direwolf/models/user';

export default class App extends Model {
  @belongsTo('user')
  declare owner: AsyncBelongsTo<User>;
}
// components/app-collaborator.ts

import Component from '@glimmer/component';
import User from 'direwolf/models/user';

interface AppCollaboratorArguments {
  model: User;
}

export default class AppCollaborator extends Component<AppCollaboratorArguments> {
  // ...
}
{{! other.hbs }}
{{!--
 interface Args {
    model: import('models/app').default';
  }
--}}
<AppCollaborator @model={{@model.owner}} />

This should cause an error, since the type of owner is AsyncBelongsTo<User> not a bare User. However, it seems that it is being typed as any and thus allowed.

If I try to call the component with another property called fail I get this error:

Argument of type '{ model: any; fail: boolean; }' is not assignable to parameter of type 'AppCollaboratorArguments'.

As you can see, it says the type of model is any.

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