-
Notifications
You must be signed in to change notification settings - Fork 27.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Omit ignored property from <Image/ > to prevent confusion (#18796)
Fixes #18793
- Loading branch information
Showing
5 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
test/integration/image-component/typescript-style/next.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
images: { | ||
domains: ['via.placeholder.com'], | ||
}, | ||
} |
19 changes: 19 additions & 0 deletions
19
test/integration/image-component/typescript-style/pages/invalid.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react' | ||
import Image from 'next/image' | ||
|
||
const Invalid = () => { | ||
return ( | ||
<div> | ||
<h1>Invalid TS</h1> | ||
<Image | ||
width={500} | ||
height={500} | ||
src="https://via.placeholder.com/500" | ||
style={{ objectFit: 'cover' }} | ||
></Image> | ||
<p id="stubtext">This is the invalid usage</p> | ||
</div> | ||
) | ||
} | ||
|
||
export default Invalid |
19 changes: 19 additions & 0 deletions
19
test/integration/image-component/typescript-style/test/index.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* eslint-env jest */ | ||
|
||
import { nextBuild } from 'next-test-utils' | ||
import { join } from 'path' | ||
|
||
jest.setTimeout(1000 * 60 * 2) | ||
|
||
const appDir = join(__dirname, '..') | ||
|
||
describe('TypeScript Image Component with Styles', () => { | ||
describe('next build', () => { | ||
it('should fail to build when the `style` prop is passed to <Image />', async () => { | ||
const { stderr, code } = await nextBuild(appDir, [], { stderr: true }) | ||
expect(stderr).toMatch(/Failed to compile/) | ||
expect(stderr).toMatch(/Property 'style' does not exist on type/) | ||
expect(code).toBe(1) | ||
}) | ||
}) | ||
}) |
19 changes: 19 additions & 0 deletions
19
test/integration/image-component/typescript-style/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"compilerOptions": { | ||
"esModuleInterop": true, | ||
"module": "esnext", | ||
"jsx": "preserve", | ||
"target": "es5", | ||
"lib": ["dom", "dom.iterable", "esnext"], | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"strict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"noEmit": true, | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true | ||
}, | ||
"exclude": ["node_modules"], | ||
"include": ["next-env.d.ts", "components", "pages"] | ||
} |