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.

Type '"fill"' is not assignable to type '"fixed" | "intrinsic" | "responsive" | undefined'.

See original GitHub issue

What version of Next.js are you using?

10.2.3

What version of Node.js are you using?

16.1.0

What browser are you using?

Chrome

What operating system are you using?

macOS

How are you deploying your application?

next start

Describe the Bug

I am using a simple next/image component:

import Image, { ImageProps } from 'next/image'

export const Img = ({ className = '', ...props }: ImageProps) => (
	<div className="unset-img full-bleed">
		<Image className={`${className} custom-img`} layout="fill" {...props} />
	</div>
)

I get red-squiggly lines on layout saying:

Type ‘“fill”’ is not assignable to type ‘“fixed” | “intrinsic” | “responsive” | undefined’.

Expected Behavior

It shouldn’t show a TS error.

To Reproduce

Clone this commit, install the dependencies & run the app. VSCode should yell.

The error is in this file. See layout="fill there.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
kb1995commented, May 27, 2021

I found this issue because I’m also experiencing the same problem when I try to pass preload={true} prop to the <Image> component.

The red-squiggly line disappears if I remove the preload prop.

import Image from "next/image";


<Image
  layout="fill"
  preload={true}
  src={image.url}
  alt={image.alt}
  objectFit="cover"
/>
1reaction
ycscholescommented, May 31, 2021

@brandonchinn178 not sure ImageProps has to do anything with it as I removed it from beside the props & it still threw an error.

Try to use the type below to replace the default ImageProps

type FillImageProps = Omit<ImageProps, 'layout' | 'height' | 'width'>;

In your case, you can do like this

import Image, { ImageProps } from 'next/image'

type FillImageProps = Omit<ImageProps, 'layout' | 'height' | 'width'>;

export const Img = ({ className = '', ...props }: FillImageProps) => (
	<div className="unset-img full-bleed">
		<Image className={`${className} custom-img`} layout="fill" {...props} />
	</div>
)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Type '"fill"' is not assignable to type '"fixed" | "intrinsic" - Reddit
I am trying to use next/image but I am getting an error: Type '"fill"' is not assignable to type '"fixed" | "intrinsic" |...
Read more >
NextjS Image issue with src and default external image URL
A little side note too: I've got a Typescript error on the layout property that says "Type '"fill"' is not assignable to type...
Read more >
Type 'string or undefined' is not assignable to type string
The "Type 'string | undefined' is not assignable to type string" error occurs when a possibly undefined value is assigned to something that...
Read more >
Next.js automatic image optimization with next/image
Learn about automatic image optimization and how it can benefit developers with the native, game-changing, and powerful next/image API.
Read more >
Type 'string' is not assignable to type 'TextAlign' - YouTube
Join this channel to get access to perks:https://www.youtube.com/channel/UCoSpmr2KNOxjwE_B9ynUmig/joinMy GearCamera ...
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