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

Dynamic import in generated .d.ts file has incorrect module name #26000

Closed
mmorearty opened this issue Jul 27, 2018 · 7 comments
Closed

Dynamic import in generated .d.ts file has incorrect module name #26000

mmorearty opened this issue Jul 27, 2018 · 7 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@mmorearty
Copy link
Contributor

mmorearty commented Jul 27, 2018

Note, this issue may look familiar, because the sample code is very similar to the sample code I posted in #25714. But this is a different (albeit perhaps related) issue.

Also, see similar issues at the bottom of this report.

TypeScript Version: 3.1.0-dev.20180727, and also 2.9.2 after I cherry-pick the fix for #25714

Search Terms:
dynamic import d.ts
relative import d.ts

Code
Here is a self-contained zip file that has:

  • build.sh, which just runs tsc with appropriate arguments
  • Five small .ts files and one small .d.ts file

repro.zip

Expected behavior:
In the generated .d.ts file, for module "projection/fields/server_computed_value_field", the declaration for getScvResult should not contain within it an import(...) that has an incorrect relative path to another module. Honestly I don't know what it's supposed to contain, but I suspect it is probably supposed to have import("projection/server_computed_value").

Actual behavior:
A relative path to another module, "../server_computed_value", was generated, when in fact the declaration of that other module appears later in the same d.ts file with a regular, non-relative name, "projection/server_computed_value". This causes my future compilations that use this d.ts file to fail.

The generated out/datastore.bundle.d.ts file includes this:

declare module "projection/fields/server_computed_value_field" {
    ...
    export const getScvResult: () => import("luna/web/tsutil/result").Result<Error, import("../server_computed_value").DatastoreServerComputedValue>;
}

declare module "projection/server_computed_value" {
    export type DatastoreServerComputedValue = null | boolean | number | string | string[];
    ...
}

Related Issues:
This looks similar to the following other issues, which were resolved as fixed: #25358, #24599

@mhegazy mhegazy added the Bug A bug in TypeScript label Jul 27, 2018
@mhegazy mhegazy added this to the TypeScript 3.1 milestone Jul 27, 2018
@mhegazy
Copy link
Contributor

mhegazy commented Jul 27, 2018

@weswigham can you take a look

@mmorearty
Copy link
Contributor Author

FYI we have ten occurrences of this in our 6,000-file codebase. Would love to see it fixed in 3.0.2 if possible!

@mmorearty
Copy link
Contributor Author

This is marked with milestone "TypeScript 3.1", but is not yet fixed in v3.1-rc. Do you still hope to fix this in 3.1?

@weswigham
Copy link
Member

I've been a weeeeee bit overprovisioned for 3.1, so.... maybe? Depends if we can get a satisfactory fix in and reviewed before the branch cut next week.

@mmorearty
Copy link
Contributor Author

haha ok :)

@weswigham
Copy link
Member

weswigham commented Sep 17, 2018

@mmorearty have you checked your project on the latest nightlies (again)? I ran your repro against master and got good output:

/// <reference path="lib/lib.d.ts" />
declare module "common/datastore_result" {
    import { Result } from "luna/web/tsutil/result";
    export type DatastoreResult<T> = Result<Error, T>;
    export type T<T> = DatastoreResult<T>;
}
declare module "common/handle_map" {
    class HandleMap<T> {
        forEach(func: (value: T, syncableId: string) => void): void;
    }
    export { HandleMap as default };
}
declare module "optimistic_updates/optimistic_updates" {
    export function updateListScv(valueMutation: any): any;
}
declare module "projection/fields/server_computed_value_field" {
    export type ScvPrimitive = null | boolean | number | string;
    export const getScvResult: () => import("luna/web/tsutil/result").Result<Error, import("projection/server_computed_value").DatastoreServerComputedValue>;
}
declare module "projection/server_computed_value" {
    export type DatastoreServerComputedValue = null | boolean | number | string | string[];
    class ServerComputedValue {
        value(): DatastoreServerComputedValue;
    }
    export { ServerComputedValue as default };
}

so this may have been a dupe of another issue we already fixed.

@mmorearty
Copy link
Contributor Author

It's fixed for me! I compiled our entire codebase with 3.1.0-dev.20180915, and it worked. 🍾

@weswigham weswigham added the Fixed A PR has been merged for this issue label Sep 17, 2018
maschino added a commit to environment-agency-austria/react-ocean-forms that referenced this issue Sep 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants