typed-ember / ember-cli-typescript

Use TypeScript in your Ember.js apps!
https://docs.ember-cli-typescript.com
MIT License
363 stars 99 forks source link

Type for Snapshot.adapterOptions is unusable #1437

Open chriskrycho opened 3 years ago

chriskrycho commented 3 years ago

Which package(s) does this problem pertain to?

What are instructions we can follow to reproduce the issue?

Reproduction Case

import DS from 'ember-data';

function useOptions(snapshot: DS.Snapshot) {
  let something = snapshot.adapterOptions.literallyAnything ?? {};
}

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

This should be typed as Record<string, unknown>.

What happened instead?

It's typed as {} and therefore goes 💥 when strict: true is set.

charlesfries commented 2 years ago

Should the adapterOptions property on SnapshotRecordArray be typed the same way? Currently it is also of type {}

charlesfries commented 2 years ago

This should be fixed by https://github.com/DefinitelyTyped/DefinitelyTyped/pull/60742