Skip to content

Commit 1e1ff40

Browse files
committed
[ts-hint] fix vscode type hint plugin enabling (#77099)
### What Fix the enabling of ts hint plugin in vscode. This is a regression introduced in #76300, where we use the plugin config `{ "name": "next" }` to directly check if it has a `enabled` property, and determine if we should enable the plugin. This PR fixed the way of reading plugin config and keep it enabled by default. Fixes 76980
1 parent 88deb12 commit 1e1ff40

File tree

1 file changed

+8
-8
lines changed
  • packages/next/src/server/typescript

1 file changed

+8
-8
lines changed

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

+8-8
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ 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-
3531
export const createTSPlugin: tsModule.server.PluginModuleFactory = ({
3632
typescript: ts,
3733
}) => {
@@ -48,10 +44,14 @@ export const createTSPlugin: tsModule.server.PluginModuleFactory = ({
4844
proxy[k] = (...args: Array<{}>) => x.apply(info.languageService, args)
4945
}
5046

51-
const pluginOptions: NextTypePluginOptions = info.config ?? {
52-
enabled: true,
53-
}
54-
if (!pluginOptions.enabled) {
47+
// Get plugin options
48+
// config is the plugin options from the user's tsconfig.json
49+
// e.g. { "plugins": [{ "name": "next", "enabled": true }] }
50+
// config will be { "name": "next", "enabled": true }
51+
// The default user config is { "name": "next" }
52+
const isPluginEnabled = info.config.enabled ?? true
53+
54+
if (!isPluginEnabled) {
5555
return proxy
5656
}
5757

0 commit comments

Comments
 (0)