question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing Types for (undocumented) setComponentTemplate API

See original GitHub issue

Edit by @chriskrycho 2022/02/10: original title was “Missing Types for new APIs”. Updated to reflect current state.


Which package(s) does this problem pertain to?

What are instructions we can follow to reproduce the issue?

Try to use any of:

  • import { dependentKeyCompat } from '@ember/object/compat';
  • import { setComponentTemplate } from '@ember/component';
  • all of ember-cli-htmlbars (but only hbs used)
Reproduction Case

If you can, please try to fork this codesandbox, and give us an example that demonstrates the problem. Paste the link below so that we can see what’s going on

  • Clone: https://github.com/NullVoxPopuli/emberclear/
  • Checkout: resolve-sidebar-performance-issues
  • cd packages/frontend/
  • Delete:
    • types/@ember/
    • types/ember-cli-htmlbars
  • in types/index.d.ts
    • Delete:
      declare module '@ember/component' {
       // TODO:  remove when this is actually a thing that exists?
       export function setComponentTemplate(template: string, klass: any): any;
      }
      
  • Run yarn lint:types
    • notice type errors raised about
      • hbs from ember-cli-htmlbars
      • setComponentTemplate from @ember/component
      • dependentKeyCompat from @ember/object/compat
tests/integration/routing/feature-flags-test.ts:4:21 - error TS7016: Could not find a declaration file for module 'ember-cli-htmlbars'. 'C:/Users/Preston/Documents/Development/NullVoxPopuli/emberclear/packages/frontend/node_modules/ember-cli-htmlbars/lib/index.js' implicitly has an 'any' type.
  Try `npm install @types/ember-cli-htmlbars` if it exists or add a new declaration (.d.ts) file containing `declare module 'ember-cli-htmlbars';`

4 import { hbs } from 'ember-cli-htmlbars';
                      ~~~~~~~~~~~~~~~~~~~~
app/components/pod/index/begin-button.ts:2:10 - error TS2614: Module '"../../../../../../../../../../../../Users/Preston/Documents/Development/NullVoxPopuli/emberclear/packages/frontend/node_modules/@types/ember__component"' has no exported member 'setComponentTemplate'. Did you mean to use 'import setComponentTemplate from "../../../../../../../../../../../../Users/Preston/Documents/Development/NullVoxPopuli/emberclear/packages/frontend/node_modules/@types/ember__component"' instead?

2 import { setComponentTemplate } from '@ember/component';
app/components/app/sidebar/chats/index.ts:4:36 - error TS2307: Cannot find module '@ember/object/compat'.

4 import { dependentKeyCompat } from '@ember/object/compat';
     

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
chriskrychocommented, Apr 6, 2022

Philosophically, I mostly agree!

Practically, there are very good reasons we haven’t allowed RFCs to be the source of truth for what we publish in our types, including that they historically haven’t necessarily matched what’s actually shipped! That’s become less a problem recently, as folks have tried to be more diligent about updating the RFC in that case, but even so, RFCs have been a poor source of truth for us.

(Here, I think with the review I did earlier today, we should be unblocked to publish the docs.)

1reaction
chriskrychocommented, Feb 10, 2022

@NullVoxPopuli

I am not really a fan of waiting to add types until there are docs.

While I can understand the sentiment, there is very good reason we do not provide types for undocumented APIs. We’ve maintained that policy for a very long time because we’re not just interested in what’s convenient now, but what is good for the long term healthy of the entire ecosystem. We have earned the trust of the Ember community and Ember’s leadership in this entirely-community-maintained (and always, remember, completely unsupported any Core team!) project by being extremely careful about things like that. In particular, we have made sure that we do not step on other people’s toes by over-specifying things which Ember itself hasn’t—and we have thereby avoided ever teaching the community to rely on TS-only features, TS-only docs, etc.

Disagreement is totally reasonable! There are tradeoffs here!—but that’s our policy and we’re not going to change it, so please accept it as a given going forward.

Happily, in the medium-term, this problem goes away because those types will be published by Ember itself, which will keep us in line much more automatically. (And I hope that Ember will also continue to improve on its discipline of documenting all of its public API!)

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do you resolve missing type errors in the @polkadot/api ...
There are a lot of missing types from the @polkadot/types/lookup folder (for example: Error: node_modules/@polkadot/api-derive/balances/types.d.
Read more >
Component - 4.8 - Ember API Documentation
Components are broken down into two categories: Components without JavaScript, that are based only on a template. These are called Template-only or TO ......
Read more >
ae-internal-missing-underscore - API Extractor
Or what if your library is consumed by JavaScript code that does not perform type checking? Adding an underscore to these declarations makes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found