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

Query param config scope: 'controller' does not type check

Open theroncross opened this issue 3 years ago • 3 comments
trafficstars

Which package(s) does this problem 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
  • [x] @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
  • [ ] Other
  • [ ] I don't know

What are instructions we can follow to reproduce the issue?

ember new sample; cd ./sample # Create a new ember app
ember install ember-cli-typescript # Set up typescript support

ember g controller application

Add

queryParams = [{
  showMagnifyingGlass: {
    scope: 'controller'
  }
}];

as described here: https://guides.emberjs.com/release/routing/query-params/#toc_sticky-query-param-values

Get a similar issue to https://github.com/typed-ember/ember-cli-typescript/issues/1295

Adding as const does not clear the warning.

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

**Link: **

Now about that bug. What did you expect to see?

I expected it to pass type check.

What happened instead?

Property 'queryParams' in type 'CollectionsDetailController' is not assignable to the same property in base type 'Controller'.
  Type '{ back: { scope: string; }; }[]' is not assignable to type '(string | Record<string, string | QueryParamConfig | undefined>)[]'.
    Type '{ back: { scope: string; }; }' is not assignable to type 'string | Record<string, string | QueryParamConfig | undefined>'.
      Type '{ back: { scope: string; }; }' is not assignable to type 'Record<string, string | QueryParamConfig | undefined>'.
        Property 'back' is incompatible with index signature.
          Type '{ scope: string; }' is not assignable to type 'string | QueryParamConfig | undefined'.
            Type '{ scope: string; }' is not assignable to type 'QueryParamConfig'.
              Types of property 'scope' are incompatible.
                Type 'string' is not assignable to type 'QueryParamScopeTypes | undefined'.ts(2416)

theroncross avatar Mar 10 '22 21:03 theroncross

Thank you for filing this! One of us will try to poke at it soon!

chriskrycho avatar Mar 15 '22 02:03 chriskrycho

@theroncross what version of the types package was this?

chriskrycho avatar Mar 15 '22 02:03 chriskrycho

❯ npm ls @types/ember
[email protected] /home/theron/webapp
├─┬ @types/[email protected]
│ └── @types/[email protected]
├─┬ @types/[email protected]
│ └── @types/[email protected] deduped
├─┬ @types/[email protected]
│ └── @types/[email protected] deduped
├─┬ @types/[email protected]
│ └── @types/[email protected] deduped
├─┬ @types/[email protected]
│ └── @types/[email protected] deduped
├─┬ @types/[email protected]
│ └── @types/[email protected] deduped
├─┬ @types/[email protected]
│ └── @types/[email protected] deduped
└─┬ @types/[email protected]
  └── @types/[email protected] deduped

theroncross avatar Mar 15 '22 15:03 theroncross

This should have been resolved by shipping types natively from Ember. If someone happens across this and finds that it is not, please file a bug on Ember itself!

chriskrycho avatar Sep 28 '23 23:09 chriskrycho