Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: option to disable next types plugin #76300

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/next/src/server/next.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 11 additions & 0 deletions packages/next/src/server/typescript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}) => {
Expand All @@ -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,
Expand Down
Loading