Unverified Commit 1708497b authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

feat: option to disable next types plugin (#76300)

parent 74c99d2b
......@@ -466,7 +466,10 @@ function createServer(
'typescript' in options &&
'version' in (options as any).typescript
) {
return require('./next-typescript').createTSPlugin(options)
const pluginMod: typeof import('./next-typescript') = require('./next-typescript')
return pluginMod.createTSPlugin(
options as any
) as unknown as NextWrapperServer
}
if (options == null) {
......
......@@ -28,6 +28,10 @@ import metadata from './rules/metadata'
import errorEntry from './rules/error'
import type tsModule from 'typescript/lib/tsserverlibrary'
type NextTypePluginOptions = {
enabled?: boolean
}
export const createTSPlugin: tsModule.server.PluginModuleFactory = ({
typescript: ts,
}) => {
......@@ -44,6 +48,13 @@ export const createTSPlugin: tsModule.server.PluginModuleFactory = ({
proxy[k] = (...args: Array<{}>) => x.apply(info.languageService, args)
}
const pluginOptions: NextTypePluginOptions = info.config ?? {
enabled: true,
}
if (!pluginOptions.enabled) {
return proxy
}
// Auto completion
proxy.getCompletionsAtPosition = (
fileName: string,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment