diff --git a/docs/api-reference/next/image.md b/docs/api-reference/next/image.md index 0d6cd03a1413a..5083bad91e3f2 100644 --- a/docs/api-reference/next/image.md +++ b/docs/api-reference/next/image.md @@ -11,6 +11,16 @@ description: Enable Image Optimization with the built-in Image component. +
+ Version History + +| Version | Changes | +| --------- | ------------------------ | +| `v10.0.1` | `layout` prop added. | +| `v10.0.0` | `next/image` introduced. | + +
+ > Before moving forward, we recommend you to read [Image Optimization](/docs/basic-features/image-optimization.md) first. Image Optimization can be enabled via the `Image` component exported by `next/image`. diff --git a/docs/basic-features/data-fetching.md b/docs/basic-features/data-fetching.md index 0a7c05aa96ce2..65f369480ab35 100644 --- a/docs/basic-features/data-fetching.md +++ b/docs/basic-features/data-fetching.md @@ -39,6 +39,17 @@ In addition, we’ll talk briefly about how to fetch data on the client side. ## `getStaticProps` (Static Generation) +
+ Version History + +| Version | Changes | +| --------- | ----------------------------------------------------------------------------------------------------------------- | +| `v10.0.0` | `locale`, `locales`, `defaultLocale`, and `notFound` options added. | +| `v9.5.0` | Stable [Incremental Static Regeneration](https://nextjs.org/blog/next-9-5#stable-incremental-static-regeneration) | +| `v9.3.0` | `getStaticProps` introduced. | + +
+ If you export an `async` function called `getStaticProps` from a page, Next.js will pre-render this page at build time using the props returned by `getStaticProps`. ```jsx @@ -364,6 +375,16 @@ This use case is supported by Next.js by the feature called **Preview Mode**. Le ## `getStaticPaths` (Static Generation) +
+ Version History + +| Version | Changes | +| -------- | ----------------------------------------------------------------------------------------------------------------- | +| `v9.5.0` | Stable [Incremental Static Regeneration](https://nextjs.org/blog/next-9-5#stable-incremental-static-regeneration) | +| `v9.3.0` | `getStaticPaths` introduced. | + +
+ If a page has dynamic routes ([documentation](/docs/routing/dynamic-routes.md)) and uses `getStaticProps` it needs to define a list of paths that have to be rendered to HTML at build time. If you export an `async` function called `getStaticPaths` from a page that uses dynamic routes, Next.js will statically pre-render all the paths specified by `getStaticPaths`. @@ -453,7 +474,7 @@ export default Post
Examples
@@ -587,6 +608,16 @@ In development (`next dev`), `getStaticPaths` will be called on every request. ## `getServerSideProps` (Server-side Rendering) +
+ Version History + +| Version | Changes | +| --------- | ------------------------------------------------------------------- | +| `v10.0.0` | `locale`, `locales`, `defaultLocale`, and `notFound` options added. | +| `v9.3.0` | `getServerSideProps` introduced. | + +
+ If you export an `async` function called `getServerSideProps` from a page, Next.js will pre-render this page on each request using the data returned by `getServerSideProps`. ```js diff --git a/packages/next/lib/typescript/runTypeCheck.ts b/packages/next/lib/typescript/runTypeCheck.ts index c789632162320..33865471af22b 100644 --- a/packages/next/lib/typescript/runTypeCheck.ts +++ b/packages/next/lib/typescript/runTypeCheck.ts @@ -33,7 +33,17 @@ export async function runTypeCheck( }) const result = program.emit() - const regexIgnoredFile = /[\\/]__(?:tests|mocks)__[\\/]|(?:spec|test)\.[^\\/]+$/ + // Intended to match: + // - pages/test.js + // - pages/apples.test.js + // - pages/__tests__/a.js + // + // But not: + // - pages/contest.js + // - pages/other.js + // - pages/test/a.js + // + const regexIgnoredFile = /[\\/]__(?:tests|mocks)__[\\/]|(?<=[\\/.])(?:spec|test)\.[^\\/]+$/ const allDiagnostics = ts .getPreEmitDiagnostics(program) .concat(result.diagnostics) diff --git a/test/integration/typescript-filtered-files/pages/contest.tsx b/test/integration/typescript-filtered-files/pages/contest.tsx new file mode 100644 index 0000000000000..32c22af551c7f --- /dev/null +++ b/test/integration/typescript-filtered-files/pages/contest.tsx @@ -0,0 +1,3 @@ +// Below type error is intentional, it helps check that we don't filter this +// file out because it's named con(test).js +export default (): boolean => 'Index page' diff --git a/test/integration/typescript-filtered-files/test/index.test.js b/test/integration/typescript-filtered-files/test/index.test.js new file mode 100644 index 0000000000000..d94a1c0d3f7d8 --- /dev/null +++ b/test/integration/typescript-filtered-files/test/index.test.js @@ -0,0 +1,17 @@ +/* eslint-env jest */ + +import { nextBuild } from 'next-test-utils' +import { join } from 'path' + +jest.setTimeout(1000 * 60 * 2) + +const appDir = join(__dirname, '..') +describe('TypeScript filtered files', () => { + it('should fail to build the app with a file named con*test*.js', async () => { + const output = await nextBuild(appDir, [], { stdout: true, stderr: true }) + expect(output.stdout).not.toMatch(/Compiled successfully/) + expect(output.code).toBe(1) + expect(output.stderr).toMatch(/Failed to compile/) + expect(output.stderr).toMatch(/is not assignable to type 'boolean'/) + }) +}) diff --git a/test/integration/typescript-filtered-files/tsconfig.json b/test/integration/typescript-filtered-files/tsconfig.json new file mode 100644 index 0000000000000..15cec79584e84 --- /dev/null +++ b/test/integration/typescript-filtered-files/tsconfig.json @@ -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"] +}