diff --git a/examples/blog-starter-typescript/next-env.d.ts b/examples/blog-starter-typescript/next-env.d.ts
index 7b7aa2c7727d88b..9bc3dd46b9d9b21 100644
--- a/examples/blog-starter-typescript/next-env.d.ts
+++ b/examples/blog-starter-typescript/next-env.d.ts
@@ -1,2 +1,6 @@
///
///
+///
+
+// NOTE: This file should not be edited
+// see https://nextjs.org/docs/basic-features/typescript for more information.
diff --git a/examples/custom-server-typescript/next-env.d.ts b/examples/custom-server-typescript/next-env.d.ts
index 7b7aa2c7727d88b..9bc3dd46b9d9b21 100644
--- a/examples/custom-server-typescript/next-env.d.ts
+++ b/examples/custom-server-typescript/next-env.d.ts
@@ -1,2 +1,6 @@
///
///
+///
+
+// NOTE: This file should not be edited
+// see https://nextjs.org/docs/basic-features/typescript for more information.
diff --git a/examples/with-aws-amplify-typescript/next-env.d.ts b/examples/with-aws-amplify-typescript/next-env.d.ts
index 7b7aa2c7727d88b..9bc3dd46b9d9b21 100644
--- a/examples/with-aws-amplify-typescript/next-env.d.ts
+++ b/examples/with-aws-amplify-typescript/next-env.d.ts
@@ -1,2 +1,6 @@
///
///
+///
+
+// NOTE: This file should not be edited
+// see https://nextjs.org/docs/basic-features/typescript for more information.
diff --git a/examples/with-chakra-ui-typescript/next-env.d.ts b/examples/with-chakra-ui-typescript/next-env.d.ts
index 7b7aa2c7727d88b..9bc3dd46b9d9b21 100644
--- a/examples/with-chakra-ui-typescript/next-env.d.ts
+++ b/examples/with-chakra-ui-typescript/next-env.d.ts
@@ -1,2 +1,6 @@
///
///
+///
+
+// NOTE: This file should not be edited
+// see https://nextjs.org/docs/basic-features/typescript for more information.
diff --git a/examples/with-electron-typescript/renderer/next-env.d.ts b/examples/with-electron-typescript/renderer/next-env.d.ts
index 7b7aa2c7727d88b..9bc3dd46b9d9b21 100644
--- a/examples/with-electron-typescript/renderer/next-env.d.ts
+++ b/examples/with-electron-typescript/renderer/next-env.d.ts
@@ -1,2 +1,6 @@
///
///
+///
+
+// NOTE: This file should not be edited
+// see https://nextjs.org/docs/basic-features/typescript for more information.
diff --git a/examples/with-expo-typescript/next-env.d.ts b/examples/with-expo-typescript/next-env.d.ts
index 7b7aa2c7727d88b..9bc3dd46b9d9b21 100644
--- a/examples/with-expo-typescript/next-env.d.ts
+++ b/examples/with-expo-typescript/next-env.d.ts
@@ -1,2 +1,6 @@
///
///
+///
+
+// NOTE: This file should not be edited
+// see https://nextjs.org/docs/basic-features/typescript for more information.
diff --git a/examples/with-ionic-typescript/next-env.d.ts b/examples/with-ionic-typescript/next-env.d.ts
index 7b7aa2c7727d88b..9bc3dd46b9d9b21 100644
--- a/examples/with-ionic-typescript/next-env.d.ts
+++ b/examples/with-ionic-typescript/next-env.d.ts
@@ -1,2 +1,6 @@
///
///
+///
+
+// NOTE: This file should not be edited
+// see https://nextjs.org/docs/basic-features/typescript for more information.
diff --git a/examples/with-mobx-state-tree-typescript/next-env.d.ts b/examples/with-mobx-state-tree-typescript/next-env.d.ts
index c6643fda12ff6f8..9bc3dd46b9d9b21 100644
--- a/examples/with-mobx-state-tree-typescript/next-env.d.ts
+++ b/examples/with-mobx-state-tree-typescript/next-env.d.ts
@@ -1,3 +1,6 @@
///
///
///
+
+// NOTE: This file should not be edited
+// see https://nextjs.org/docs/basic-features/typescript for more information.
diff --git a/examples/with-mysql/next-env.d.ts b/examples/with-mysql/next-env.d.ts
index 7b7aa2c7727d88b..9bc3dd46b9d9b21 100644
--- a/examples/with-mysql/next-env.d.ts
+++ b/examples/with-mysql/next-env.d.ts
@@ -1,2 +1,6 @@
///
///
+///
+
+// NOTE: This file should not be edited
+// see https://nextjs.org/docs/basic-features/typescript for more information.
diff --git a/examples/with-next-sitemap/next-env.d.ts b/examples/with-next-sitemap/next-env.d.ts
index 7b7aa2c7727d88b..9bc3dd46b9d9b21 100644
--- a/examples/with-next-sitemap/next-env.d.ts
+++ b/examples/with-next-sitemap/next-env.d.ts
@@ -1,2 +1,6 @@
///
///
+///
+
+// NOTE: This file should not be edited
+// see https://nextjs.org/docs/basic-features/typescript for more information.
diff --git a/examples/with-paste-typescript/next-env.d.ts b/examples/with-paste-typescript/next-env.d.ts
index 7b7aa2c7727d88b..9bc3dd46b9d9b21 100644
--- a/examples/with-paste-typescript/next-env.d.ts
+++ b/examples/with-paste-typescript/next-env.d.ts
@@ -1,2 +1,6 @@
///
///
+///
+
+// NOTE: This file should not be edited
+// see https://nextjs.org/docs/basic-features/typescript for more information.
diff --git a/examples/with-react-intl/next-env.d.ts b/examples/with-react-intl/next-env.d.ts
index 7b7aa2c7727d88b..9bc3dd46b9d9b21 100644
--- a/examples/with-react-intl/next-env.d.ts
+++ b/examples/with-react-intl/next-env.d.ts
@@ -1,2 +1,6 @@
///
///
+///
+
+// NOTE: This file should not be edited
+// see https://nextjs.org/docs/basic-features/typescript for more information.
diff --git a/examples/with-react-md-typescript/next-env.d.ts b/examples/with-react-md-typescript/next-env.d.ts
index 7b7aa2c7727d88b..9bc3dd46b9d9b21 100644
--- a/examples/with-react-md-typescript/next-env.d.ts
+++ b/examples/with-react-md-typescript/next-env.d.ts
@@ -1,2 +1,6 @@
///
///
+///
+
+// NOTE: This file should not be edited
+// see https://nextjs.org/docs/basic-features/typescript for more information.
diff --git a/examples/with-redux-toolkit-typescript/next-env.d.ts b/examples/with-redux-toolkit-typescript/next-env.d.ts
index c6643fda12ff6f8..9bc3dd46b9d9b21 100644
--- a/examples/with-redux-toolkit-typescript/next-env.d.ts
+++ b/examples/with-redux-toolkit-typescript/next-env.d.ts
@@ -1,3 +1,6 @@
///
///
///
+
+// NOTE: This file should not be edited
+// see https://nextjs.org/docs/basic-features/typescript for more information.
diff --git a/examples/with-reflexjs/next-env.d.ts b/examples/with-reflexjs/next-env.d.ts
new file mode 100644
index 000000000000000..9bc3dd46b9d9b21
--- /dev/null
+++ b/examples/with-reflexjs/next-env.d.ts
@@ -0,0 +1,6 @@
+///
+///
+///
+
+// NOTE: This file should not be edited
+// see https://nextjs.org/docs/basic-features/typescript for more information.
diff --git a/examples/with-storybook-styled-jsx-scss/next-env.d.ts b/examples/with-storybook-styled-jsx-scss/next-env.d.ts
index 7b7aa2c7727d88b..9bc3dd46b9d9b21 100644
--- a/examples/with-storybook-styled-jsx-scss/next-env.d.ts
+++ b/examples/with-storybook-styled-jsx-scss/next-env.d.ts
@@ -1,2 +1,6 @@
///
///
+///
+
+// NOTE: This file should not be edited
+// see https://nextjs.org/docs/basic-features/typescript for more information.
diff --git a/examples/with-stripe-typescript/next-env.d.ts b/examples/with-stripe-typescript/next-env.d.ts
index 0ed4fc8ed494fa6..9bc3dd46b9d9b21 100644
--- a/examples/with-stripe-typescript/next-env.d.ts
+++ b/examples/with-stripe-typescript/next-env.d.ts
@@ -1,2 +1,6 @@
-///
-///
+///
+///
+///
+
+// NOTE: This file should not be edited
+// see https://nextjs.org/docs/basic-features/typescript for more information.
diff --git a/examples/with-typescript-eslint-jest/next-env.d.ts b/examples/with-typescript-eslint-jest/next-env.d.ts
index 7b7aa2c7727d88b..9bc3dd46b9d9b21 100644
--- a/examples/with-typescript-eslint-jest/next-env.d.ts
+++ b/examples/with-typescript-eslint-jest/next-env.d.ts
@@ -1,2 +1,6 @@
///
///
+///
+
+// NOTE: This file should not be edited
+// see https://nextjs.org/docs/basic-features/typescript for more information.
diff --git a/examples/with-typescript-graphql/graphql.d.ts b/examples/with-typescript-graphql/graphql.d.ts
new file mode 100644
index 000000000000000..d0cab7295668b25
--- /dev/null
+++ b/examples/with-typescript-graphql/graphql.d.ts
@@ -0,0 +1,6 @@
+declare module '*.graphqls' {
+ import { DocumentNode } from 'graphql'
+ export default typeof DocumentNode
+}
+
+declare module '*.yml'
diff --git a/examples/with-typescript-graphql/next-env.d.ts b/examples/with-typescript-graphql/next-env.d.ts
index a6b5cc5a189f6e9..9bc3dd46b9d9b21 100644
--- a/examples/with-typescript-graphql/next-env.d.ts
+++ b/examples/with-typescript-graphql/next-env.d.ts
@@ -1,9 +1,6 @@
///
///
+///
-declare module '*.graphqls' {
- import { DocumentNode } from 'graphql'
- export default typeof DocumentNode
-}
-
-declare module '*.yml'
+// NOTE: This file should not be edited
+// see https://nextjs.org/docs/basic-features/typescript for more information.
diff --git a/examples/with-typescript-graphql/tsconfig.json b/examples/with-typescript-graphql/tsconfig.json
index 93a83a407c40c84..d903e6e706d5a1b 100644
--- a/examples/with-typescript-graphql/tsconfig.json
+++ b/examples/with-typescript-graphql/tsconfig.json
@@ -14,6 +14,6 @@
"isolatedModules": true,
"jsx": "preserve"
},
- "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
+ "include": ["next-env.d.ts", "graphql.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
diff --git a/examples/with-typescript-styled-components/next-env.d.ts b/examples/with-typescript-styled-components/next-env.d.ts
index 7b7aa2c7727d88b..9bc3dd46b9d9b21 100644
--- a/examples/with-typescript-styled-components/next-env.d.ts
+++ b/examples/with-typescript-styled-components/next-env.d.ts
@@ -1,2 +1,6 @@
///
///
+///
+
+// NOTE: This file should not be edited
+// see https://nextjs.org/docs/basic-features/typescript for more information.
diff --git a/examples/with-typescript-types/next-env.d.ts b/examples/with-typescript-types/next-env.d.ts
index 7b7aa2c7727d88b..9bc3dd46b9d9b21 100644
--- a/examples/with-typescript-types/next-env.d.ts
+++ b/examples/with-typescript-types/next-env.d.ts
@@ -1,2 +1,6 @@
///
///
+///
+
+// NOTE: This file should not be edited
+// see https://nextjs.org/docs/basic-features/typescript for more information.
diff --git a/examples/with-typescript/next-env.d.ts b/examples/with-typescript/next-env.d.ts
index 7b7aa2c7727d88b..9bc3dd46b9d9b21 100644
--- a/examples/with-typescript/next-env.d.ts
+++ b/examples/with-typescript/next-env.d.ts
@@ -1,2 +1,6 @@
///
///
+///
+
+// NOTE: This file should not be edited
+// see https://nextjs.org/docs/basic-features/typescript for more information.
diff --git a/examples/with-unsplash/next-env.d.ts b/examples/with-unsplash/next-env.d.ts
index 7b7aa2c7727d88b..9bc3dd46b9d9b21 100644
--- a/examples/with-unsplash/next-env.d.ts
+++ b/examples/with-unsplash/next-env.d.ts
@@ -1,2 +1,6 @@
///
///
+///
+
+// NOTE: This file should not be edited
+// see https://nextjs.org/docs/basic-features/typescript for more information.
diff --git a/packages/create-next-app/create-app.ts b/packages/create-next-app/create-app.ts
index 2badeabb1bf4392..c06ea76227a54a8 100644
--- a/packages/create-next-app/create-app.ts
+++ b/packages/create-next-app/create-app.ts
@@ -169,6 +169,15 @@ export async function createApp({
)
}
+ // Copy default `next-env.d.ts` to any example that is typescript
+ const tsconfigPath = path.join(root, 'tsconfig.json')
+ if (fs.existsSync(tsconfigPath)) {
+ fs.copyFileSync(
+ path.join(__dirname, 'templates', 'typescript', 'next-env.d.ts'),
+ path.join(root, 'next-env.d.ts')
+ )
+ }
+
console.log('Installing packages. This might take a couple of minutes.')
console.log()
diff --git a/packages/create-next-app/templates/typescript/next-env.d.ts b/packages/create-next-app/templates/typescript/next-env.d.ts
index c6643fda12ff6f8..9bc3dd46b9d9b21 100644
--- a/packages/create-next-app/templates/typescript/next-env.d.ts
+++ b/packages/create-next-app/templates/typescript/next-env.d.ts
@@ -1,3 +1,6 @@
///
///
///
+
+// NOTE: This file should not be edited
+// see https://nextjs.org/docs/basic-features/typescript for more information.
diff --git a/scripts/check-examples.sh b/scripts/check-examples.sh
index 6ea4368dd67d5dd..e1bd31cf06d3462 100755
--- a/scripts/check-examples.sh
+++ b/scripts/check-examples.sh
@@ -5,6 +5,9 @@ for folder in examples/* ; do
if [ -f "$folder/package.json" ]; then
cat $folder/package.json | jq '.license = "MIT" | .private = true' | sponge $folder/package.json
fi
+ if [ -f "$folder/tsconfig.json" ]; then
+ cp packages/create-next-app/templates/typescript/next-env.d.ts $folder/next-env.d.ts
+ fi
done;
if [[ ! -z $(git status -s) ]];then