Skip to content

Use minimal endings when generating declarations for js #41070

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

Conversation

weswigham
Copy link
Member

@weswigham weswigham commented Oct 12, 2020

Fixes #34624

Fun fact! This was mostly fixed with the addition of the bundledPackageName flag. All that was missing was passing in an option to our specifier generator for (bundled) js declaration emit. The declaration file we generate (when you add "bundledPackageName": "mylib") now looks like

declare module "mylib/versions.static" {
    var _default: {
        "@a/b": string;
        "@a/c": string;
    };
    export default _default;
}
declare module "mylib" {
    export { versions };
    import versions from "mylib/versions.static";
}

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Oct 12, 2020
@weswigham weswigham requested review from orta and sandersn October 12, 2020 23:04
@@ -5479,7 +5479,7 @@ namespace ts {
specifierCompilerOptions,
contextFile,
moduleResolverHost,
{ importModuleSpecifierPreference: isBundle ? "non-relative" : "relative" },
{ importModuleSpecifierPreference: isBundle ? "non-relative" : "relative", importModuleSpecifierEnding: isBundle ? "minimal" : undefined },
Copy link
Member

Choose a reason for hiding this comment

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

Maybe this is easier to read? But maybe not, I just wanted to write it out for comparison.

Suggested change
{ importModuleSpecifierPreference: isBundle ? "non-relative" : "relative", importModuleSpecifierEnding: isBundle ? "minimal" : undefined },
isBundle ? { importModuleSpecifierPreference: "non-relative", importModuleSpecifierEnding: "minimal" } : { importModuleSpecifierPreference: "relative" },

Copy link
Member Author

Choose a reason for hiding this comment

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

Eh, I think I prefer having the single object literal, even if the condition happens to be the same for both fields.

@weswigham weswigham merged commit ce1947b into microsoft:master Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

module name mismatch in declaration
3 participants