Skip to content

Commit 1708497

Browse files
authored
feat: option to disable next types plugin (#76300)
1 parent 74c99d2 commit 1708497

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

packages/next/src/server/next.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,10 @@ function createServer(
466466
'typescript' in options &&
467467
'version' in (options as any).typescript
468468
) {
469-
return require('./next-typescript').createTSPlugin(options)
469+
const pluginMod: typeof import('./next-typescript') = require('./next-typescript')
470+
return pluginMod.createTSPlugin(
471+
options as any
472+
) as unknown as NextWrapperServer
470473
}
471474

472475
if (options == null) {

packages/next/src/server/typescript/index.ts

+11
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ import metadata from './rules/metadata'
2828
import errorEntry from './rules/error'
2929
import type tsModule from 'typescript/lib/tsserverlibrary'
3030

31+
type NextTypePluginOptions = {
32+
enabled?: boolean
33+
}
34+
3135
export const createTSPlugin: tsModule.server.PluginModuleFactory = ({
3236
typescript: ts,
3337
}) => {
@@ -44,6 +48,13 @@ export const createTSPlugin: tsModule.server.PluginModuleFactory = ({
4448
proxy[k] = (...args: Array<{}>) => x.apply(info.languageService, args)
4549
}
4650

51+
const pluginOptions: NextTypePluginOptions = info.config ?? {
52+
enabled: true,
53+
}
54+
if (!pluginOptions.enabled) {
55+
return proxy
56+
}
57+
4758
// Auto completion
4859
proxy.getCompletionsAtPosition = (
4960
fileName: string,

0 commit comments

Comments
 (0)