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

Rare bug in outFile #26

Closed
steveruizok opened this issue Feb 6, 2022 · 1 comment
Closed

Rare bug in outFile #26

steveruizok opened this issue Feb 6, 2022 · 1 comment

Comments

@steveruizok
Copy link

I've generally used this package with a config that uses an outDir, however I gave outFile a shot and noticed a few misses!

In a project where I had a folder named types with an index.ts, my import is import types from "~types". When I build this to a single declaration file with outFile, the import is (in certain places) converted to import("types"), rather than `import("types/index").

The types are being processed, but perhaps incorrectly.

It's always where the type is imported "inline" as shown:

declare module "lib/TLBush/TLBush" {
    import RBush from 'rbush';
    import type { TLShape } from "lib/TLShape/index";
    export class TLBush<S extends TLShape> extends RBush<S> {
        toBBox: (shape: S) => import("types").TLBounds;
    }
}

The correct result would be:

declare module "lib/TLBush/TLBush" {
    import RBush from 'rbush';
    import type { TLShape } from "lib/TLShape/index";
    export class TLBush<S extends TLShape> extends RBush<S> {
        toBBox: (shape: S) => import("types/index").TLBounds;
    }
}

Without tsconfig-replace-paths, I get:

declare module "lib/TLBush/TLBush" {
    import RBush from 'rbush';
    import type { TLShape } from "lib/TLShape/index";
    export class TLBush<S extends TLShape> extends RBush<S> {
        toBBox: (shape: S) => import("~types").TLBounds;
    }
}

Which also shows an error.

Another example where the import is resolved to ./types rather than types/index.

declare module "lib/TLApp/TLSceneGraph/TLSceneGraph" {
    import { TLApp, TLShape } from "lib/index";
    export class TLSceneGraph<S extends TLShape> {
        constructor(app: TLApp<S>, document: TLDocumentModel<S>);
        app: TLApp<S>;
       // snip
        toJSON: () => {
            shapes: {
                [k: string]: import("./types").TLShapeModel;
            };
            bindings: {
                [k: string]: TLBinding;
            };
        };
    }
}

(P.S. Thanks for this package, it's great!)

@jonkwheeler
Copy link
Owner

I've tried replicating, but I'm unsuccessful.

My tsconfig has "~types": ["./src/props"]

File has import { RootProps } from '~types'

Output is import { RootProps } from '../../props';

It doesn't output to '../../props/index', but it doesn't need to in my case.

Am I missing something?

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

2 participants