-
Notifications
You must be signed in to change notification settings - Fork 6
Description
In the app/page.tsx
file in the Next.js app dir example cmd
-clicking on the styles.code
property to trigger Go to Definition in VS Code shows an extra entry of the node_modules/next/types/global.d.ts
file with the *.module.css
type definition.
This makes it no longer a one-click Go to Definition interaction. It would be great to get rid of these generic *.module.css
/ *.module.scss
/ *.module.sass
entries so that it's a single click again.
This is also a problem with other extensions:
Potential approach
It seems that @zardoy has found a potentially interesting approach in his extension TypeScript Essential Plugins (repo). Some interesting parts of the code:
proxy.getDefinitionAndBoundSpan = (fileName, position) => {
const prior = info.languageService.getDefinitionAndBoundSpan(fileName, position)
// ...
prior.definitions = prior.definitions.filter(({ fileName, containerName, containerKind, kind, name, ...rest }) => {
// ...
if (moduleDeclaration?.name.text === '*.module.css') return false
return true
})
// ...
})
- https://github.com/zardoy/typescript-vscode-plugins/blob/a102a76786a0292aa8a9a46fb6cc43595e8871a7/typescript/src/definitions.ts#L7-L8
- https://github.com/zardoy/typescript-vscode-plugins/blob/a102a76786a0292aa8a9a46fb6cc43595e8871a7/typescript/src/definitions.ts#L123
- https://github.com/zardoy/typescript-vscode-plugins/blob/a102a76786a0292aa8a9a46fb6cc43595e8871a7/typescript/src/definitions.ts#L141
If I'm understanding correctly, this is filtering out previous definitions if they have the name *.module.css
, which could also be extended to include *.module.scss
and *.module.sass
.