TypeScript Doesn't Read Type Definition Files? #316
-
| Hi, I created the following structure on the demo page: My expectation was that when I imported the module named  node_modules/@types/logger/index.d.ts declare class Logger {
    constructor(name: string);
    info(msg: string): void;
}node_modules/logger/index.js class Logger {
    constructor(name) {}
    info(msg) {}
}
export default Logger;main.ts import Logger from "logger";
const logger = new Logger();
logger.// No autocomplete.Did I miss something? | 
Beta Was this translation helpful? Give feedback.
      
      
          Answered by
          
            cemalgnlts
          
      
      
        Jan 18, 2024 
      
    
    Replies: 1 comment 8 replies
-
| Does it work in VSCode? | 
Beta Was this translation helpful? Give feedback.
                  
                    8 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    


I found a strange solution. The folder structure should be like this:
package.json should be like this:
{ "name": "logger", "version": "1.0.0", "types": "./dist/logger.d.ts" }There must be a dist folder, the name of the type file must be the same as the package file.
I also found out why you don't detect semantic errors. I changed the
typescript.tsserver.web.projectWideIntellisense.suppressSemanticErrorssetting tofalseand now autocomplete works and semantic errors are also shown.Thanks!