diff --git a/packages/next/client/image.tsx b/packages/next/client/image.tsx index 9c7052f538241b3..14cf4abe185f329 100644 --- a/packages/next/client/image.tsx +++ b/packages/next/client/image.tsx @@ -157,7 +157,7 @@ export default function Image({ if (priority && lazy) { if (process.env.NODE_ENV !== 'production') { throw new Error( - `Image with src ${src} has both priority and lazy properties. Only one should be used.` + `Image with src "${src}" has both "priority" and "lazy" properties. Only one should be used.` ) } } @@ -254,14 +254,15 @@ export default function Image({ if (priority) { // console.warn( - `Image with src ${src} has both priority and unsized attributes. Only one should be used.` + `Image with src "${src}" has both "priority" and "unsized" properties. Only one should be used.` ) } } } else { + // if (process.env.NODE_ENV !== 'production') { - console.error( - `Image with src ${src} must use width and height attributes or unsized attribute.` + throw new Error( + `Image with src "${src}" must use "width" and "height" properties or "unsized" property.` ) } } diff --git a/test/integration/image-component/typescript/test/index.test.js b/test/integration/image-component/typescript/test/index.test.js index b163b2b1304d59c..16424caff5ed966 100644 --- a/test/integration/image-component/typescript/test/index.test.js +++ b/test/integration/image-component/typescript/test/index.test.js @@ -45,14 +45,14 @@ describe('TypeScript Image Component', () => { const html = await renderViaHTTP(appPort, '/valid', {}) expect(html).toMatch(/This is valid usage of the Image component/) expect(output).not.toMatch( - /must use width and height attributes or unsized attribute/ + /must use "width" and "height" properties or "unsized" property/ ) }) it('should print error when invalid Image usage', async () => { await renderViaHTTP(appPort, '/invalid', {}) expect(output).toMatch( - /must use width and height attributes or unsized attribute/ + /must use "width" and "height" properties or "unsized" property/ ) }) })