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

doc: Please add an example how to export functions/classes from my own lib #79

Closed
MikeMitterer opened this issue Nov 22, 2018 · 2 comments

Comments

@MikeMitterer
Copy link

I want to expose some of my TS-classes to 'window' but I have no idea how to automate this process with expose-loader...

At the moment I'm doing it manually like so: (exports.ts)
(just in case someone else has the same problem...)

import { Name as NameToExport } from "./address/Name";
import {
    addValues as addValuesToExport,
    sayMyName as sayMyNameToExport,
} from "./index";

declare global {
    namespace MyLib {
        export type Name = NameToExport;
        export const Name: typeof NameToExport;

        export const addValues: typeof addValuesToExport;
        export const sayMyName: typeof sayMyNameToExport;
    }
}

(window as any).MyLib = {
    Name: NameToExport,
    addValues: addValuesToExport,
    sayMyName: sayMyNameToExport,
};

I'm using webpack 4 and TS 3

@alexander-akait
Copy link
Member

Is not implemented yes, will be part of the next release

@alexander-akait
Copy link
Member

Fixed, but you need to specify custom custom-type-definitions-to-a-third-party-library in your application manually , here examples https://www.detroitlabs.com/blog/2018/02/28/adding-custom-type-definitions-to-a-third-party-library/

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