-
Notifications
You must be signed in to change notification settings - Fork 24
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
How Do you import this from typescript and use it? #171
Comments
Try adding a Ensure that TypeScript is aware of this file by including its path in your tsconfig.json: {
"include": ["src/**/*", "@types/**/*"]
}
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. |
Just added latest, it does not appear to export any type info:
Restarting TS server did not work, but also I haven't had such a problem with any other package. It's strange because I can see the type definitions in the module folder, but VSCode doesn't seem to want to use them. UPDATE: You can see yourself here: https://github.com/rhys-vdw/lua-doc-extractor/tree/d6676877e5e1d9802ddb832941b998b14cf02400 |
I tried many variations but nothing works
The text was updated successfully, but these errors were encountered: