Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Typescript 5.4.5: Cannot read properties of undefined (reading 'getSourceFile') #265

Open
hambergerpls opened this issue May 27, 2024 · 1 comment
Labels
question Further information is requested

Comments

@hambergerpls
Copy link

hambergerpls commented May 27, 2024

Describe the bug
I'm trying to set up customTemplate option in tsconfig.json.

For testing, I use the following customTemplate.js:

module.exports = (dts, { classes, fileName, logger }) => {
    return dts;
};

But received the following error,

tsserver: 1: <semantic> TypeScript Server Error (5.4.5)
Cannot read properties of undefined (reading 'getSourceFile')                                                                                                                                                                                 TypeError: Cannot read properties of undefined (reading 'getSourceFile')
at ./node_modules/typescript/lib/tsserver.js:146667:82
at mapDefined (./node_modules/typescript/lib/tsserver.js:2680:22)
at Object.getDocumentHighlights (./node_modules/typescript/lib/tsserver.js:146667:33)
at IpcIOSession.getDocumentHighlights (./node_modules/typescript/lib/tsserver.js:186370:61)
at documentHighlights (./node_modules/typescript/lib/tsserver.js:185337:43)
at ./node_modules/typescript/lib/tsserver.js:187569:69
at IpcIOSession.executeWithRequestId (./node_modules/typescript/lib/tsserver.js:187561:14)
at IpcIOSession.executeCommand (./node_modules/typescript/lib/tsserver.js:187569:29)
at IpcIOSession.onMessage (./node_modules/typescript/lib/tsserver.js:187611:51)
at process.<anonymous> (./node_modules/typescript/lib/tsserver.js:189220:14)
at process.emit (node:events:518:28)
at emit (node:internal/child_process:951:14)
at process.processTicksAndRejections (node:internal/process/task_queues:83:21)   

I'm using Neovim as my IDE.

The goal is that I want to add additional variable export for my .module.scss like the following:

   declare module "*.module.scss" {
        const classes: { [key: string]: string };
 	export const code: string;
 	export default classes;
 }

I tried to create this declaration file like custom.d.ts, but the LSP fails to detect code as exported member when I import it:

import styles, { code } from "./test.module.scss"; // Module has no exported member 'code' ...

Since, I couldn't get the custom template to work, I had to modify the source createDtsExports.js and export code from there as a temporary solution.

@mrmckeb
Copy link
Owner

mrmckeb commented Oct 10, 2024

Hi @hambergerpls, are you able to provide a reproduction? I can then dig into the issue and see if it's a configuration problem or something we can fix within the plugin.

@mrmckeb mrmckeb added the question Further information is requested label Oct 10, 2024
@mrmckeb mrmckeb modified the milestone: v6.0.0 Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants