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

feat: support dynamic imports with addRelativeDeclarationExtensions #269

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cjpearson
Copy link

#267

This patch extends the addRelativeDeclarationExtensions functionality to also add the extension when import() is used.

Before:

export * from "./other.js";
export type { Other } from "./other.js";
export declare function wonder(twinkle: import("./other").Other): string;

After:

export * from "./other.js";
export type { Other } from "./other.js";
export declare function wonder(twinkle: import("./other.js").Other): string;

(dynamicImport) => {
let specifier: string | undefined;
try {
const value = JSON.parse(dynamicImport.expression);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A simpler option might be to take a substring, but I wasn't sure if there might a case with an actual dynamic import where the expression is not a string literal but it still passes the RELATIVE_RE test.

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

Successfully merging this pull request may close these issues.

1 participant