pearofducks/svelte-match-media

Property 'media' does not exist on type '() => { media: Readable<{ [name: string]: boolean; }>; }'. Why?

Closed this issue · 3 comments

First of all thanks for your work!

Using it like this for the first time today with TS:

import { createMedia } from "svelte-match-media";

const breakpoints = {
	sm: "screen and (max-width: 767px)",
	lg: "screen and (min-width: 1024px)",
};

const { media } = createMedia(breakpoints);

console.log("media:", media);

I get this error:

Property 'media' does not exist on type '() => { media: Readable<{ [name: string]: boolean; }>; }'. ts(2339)

Why? It's my fault?

image

Do you have a link to a reproduction repo? There's a lot of things that could be going wrong with TS to diagnose this.

The type definition looks right FWIW.

Do you have a link to a reproduction repo?

Here it is: https://github.com/frederikhors/svelte-match-media-issue-12

npm install
npm run validate

and you can read the error:

Error: Property 'media' does not exist on type '() => { media: Readable<{ [name: string]: boolean; }>; }'. (ts)

  const { media } = createMedia(breakpoints);

Fixed in 1.2.1 - thanks for reporting this!