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

Add @types/ember__helper for `@ember/helper`

Open NullVoxPopuli opened this issue 4 years ago • 8 comments
trafficstars

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
  • [ ] @types/ember__component
  • [ ] @types/ember__routing
  • [ ] @types/ember__application
  • [ ] @types/ember__test
  • [ ] @types/ember__test-helpers
  • [ ] @types/ember__service
  • [ ] @types/ember-data
  • [ ] @types/rsvp
  • [x] Other
  • [ ] I don't know

Please write a user story for this feature

In recent ember, @ember/helper is availble for import, including apis such as:

  • invokeHelper
  • capabilities
  • setHelperManager

Additionally, with template-strict mode, these will be required (but are available today)

  • fn
  • hash
  • array
  • if
  • concat
  • get
  • etc?

Here is the current (to be updated docs): https://api.emberjs.com/ember/release/modules/@ember%2Fhelper List of what's also available: https://github.com/emberjs/rfcs/blob/master/text/0496-handlebars-strict-mode.md#keywords

NullVoxPopuli avatar Jul 08 '21 13:07 NullVoxPopuli

Thanks for opening. As per the usual, if you can help land docs on the importable helpers, that'll be great (we always follow the "don't add things to DT that aren't documented" policy).

chriskrycho avatar Jul 08 '21 17:07 chriskrycho

can do!

NullVoxPopuli avatar Jul 08 '21 18:07 NullVoxPopuli

lol, look at me the liar :sweat_smile:

NullVoxPopuli avatar Feb 10 '22 15:02 NullVoxPopuli

I believe (we should check) that this is fixed now! @dfreeman opened a PE with it a week or so ago.

chriskrycho avatar Feb 10 '22 17:02 chriskrycho

I added the strict-mode helper imports, but the manager APIs are still missing if those are what you're after

dfreeman avatar Feb 10 '22 18:02 dfreeman

if those are what you're after

they are what I'm after :tada: they're handy for resources.

atm, I have a lot of:

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import { createCache, getValue } from '@glimmer/tracking/primitives/cache';
import { setOwner } from '@ember/application';
import { associateDestroyableChild, registerDestructor } from '@ember/destroyable';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import { capabilities as helperCapabilities, setHelperManager } from '@ember/helper';

:sweat_smile:

NullVoxPopuli avatar Feb 10 '22 18:02 NullVoxPopuli

@dfreeman

I can try a PR at the manager API stuff.

The main question I have, is what does the Cache API look like? does that have types? (because invokeHelper takes a Cache) -- how would we add types to glimmer/tracking? do we first need to make glimmer/tracking a real npm package?

NullVoxPopuli avatar Mar 31 '22 00:03 NullVoxPopuli

The problem here is exactly that @glimmer/tracking is a real npm package, and it ships types already, but the package itself has no primitives/cache subpath—that only exists for Ember consumers via smoke and mirrors.

I think @chriskrycho has the best depth of knowledge on this particular problem space (he's been the one to map out a path forward for the same "what you see is not what you get" issue with @glimmer/component), but I don't know if he's had the bandwidth to give this much thought yet, and/or whether he will any time in the near future.

On the bright side, it looks like capabilities and setHelperManager are both fully documented, and we've got established patterns in DT for their component equivalents, so adding declarations for those should be relatively straightforward 🙂

dfreeman avatar Mar 31 '22 07:03 dfreeman

Resolved by Ember shipping its own types. 🎉

chriskrycho avatar Sep 28 '23 23:09 chriskrycho