ember-cli-typescript icon indicating copy to clipboard operation
ember-cli-typescript copied to clipboard

It should be possible to specify the types for a template only component

Open akatz opened this issue 4 years ago • 2 comments

Which package(s) does this enhancement pertain to?

  • [ ] @types/ember
  • [ ] @types/ember__string
  • [ ] @types/ember__polyfills
  • [ ] @types/ember__object
  • [ ] @types/ember__utils
  • [ ] @types/ember__array
  • [ ] @types/ember__engine
  • [ ] @types/ember__debug
  • [ ] @types/ember__runloop
  • [ ] @types/ember__error
  • [ ] @types/ember__controller
  • [x] @types/ember__component
  • [ ] @types/ember__routing
  • [ ] @types/ember__application
  • [ ] @types/ember__test
  • [ ] @types/ember__test-helpers
  • [ ] @types/ember__service
  • [ ] @types/ember-data
  • [ ] @types/rsvp
  • [ ] Other
  • [ ] I don't know

As an app or addon developer I want to be able to specify the args for a template only component that could potentially be used at the call site to statically validate the type of the props being passed in.

akatz avatar Dec 29 '20 06:12 akatz

Thanks for filing this! You can technically do this today by creating a .ts file which imports the corresponding template and then exports it again with the templateOnly wrapper. However, it's very much non-ergonomic! Additionally, it of course doesn't have any impact on actual type-checking… as nothing does yet. This is a key part of the design space we're exploring for template imports and for our still-in-private-alpha-because-very-much-not-fully-ready language server integration.

chriskrycho avatar Jan 02 '21 17:01 chriskrycho

Follow-on to the above: we specifically need to make it possible to set the "type" of a templateOnly component!

chriskrycho avatar Jan 02 '21 17:01 chriskrycho

This is now done, via the combination of Ember's own templateOnlyComponent() API and the design of Ember's Signature types. 🎉

chriskrycho avatar Sep 28 '23 22:09 chriskrycho