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

NEW API:SourceFile.addGlobalDeclare #1565

Open
peterroe opened this issue Aug 19, 2024 · 0 comments
Open

NEW API:SourceFile.addGlobalDeclare #1565

peterroe opened this issue Aug 19, 2024 · 0 comments

Comments

@peterroe
Copy link

peterroe commented Aug 19, 2024

Can we add an API for generating declare modules?

My code now:

const sourceFile = project.createSourceFile(/*...*/)

// some code...

sourceFile.insertText(
        sourceFile.getEnd(),
        `
declare global {
    declare const __DEV__: boolean;
    declare const __EDITOR__: boolean;
    declare const PW: PW;

    interface Window {
        require: (name: string) => unknown;
        PW: PW;
    }
}
`
    );

My preferred usage:

const dm = sourceFile.addGlobalDeclare({
	// more options
})

If the idea is deemed viable, I would happily pull a request.

@peterroe peterroe changed the title NEW API:SourceFile.addDeclareModule NEW API:SourceFile.addGlobalDeclare Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant