Open radiantone opened 5 months ago
Try adding a comment-parser.d.ts
file in. a @types
folder in your root or src folder
Ensure that TypeScript is aware of this file by including its path in your tsconfig.json:
{
"include": ["src/**/*", "@types/**/*"]
}
comment-parser.d.ts
declare module 'comment-parser' {
import { ParsedComment } from 'comment-parser/lib/types'; // Adjust import path if necessary
export function parse(source: string): ParsedComment[];
}
or
declare module 'comment-parser' {
interface Tag {
tag: string;
name: string;
type?: string;
optional?: boolean;
default?: string;
description: string;
problems: any[];
source: string[];
}
interface ParsedComment {
description: string;
tags: Tag[];
}
export function parse(source: string): ParsedComment[];
}
Should be no need for a declaration file.
import {parse as commentParser} from 'comment-parser';
// See the structure yourself
console.log(
commentParser(`
/**
* @param {someType} someName A description
*/
`)
);
I got it working with the above solution, but sometimes it is just a local TS server issue. I've seen that frequently with VS Code. Sometimes it can be solved via Cmd-P Restart TS Server, sometime with a full reboot of the IDE.
I tried many variations but nothing works