Skip to content

TypeScript types pollute the global namespace #1078

@mfulton26

Description

@mfulton26

I am setting up embedding CCP iframes inside their own iframes (to enable multiple embedded CCPs as well as enabling the ability to fully dispose of an initialized CCP by destroying the iframe in which a CCP's iframe is embedded).

While doing this I have found it difficult to get good TypeScript support because if I place import "amazon-connect-streams"; in any of my modules then the declared connect namespace gets globally defined but when using embedded CCPs the connect object is not availabe in the main document but online inside each of its iframes in which each CCP iframe is initialized.

Can some alternative way to import the types be set up to provide better type-safety for those not using global augmentation in their main browser context?

e.g. If all the types inside index.d.ts were moved to a new types file, exported as a module, and then index.d.ts were to re-export those types as a namespace then code today relying on global type augmentation via import "amazon-connect-streams"; would continue to work while new code could be defined to import code and types without polluting the global namespace.

I don't know if addressing the TypeScript types would require packaging the code differently but ultimatley I am looking from something more ESM friendly. e.g.:

import { initCCP, type Agent } from "amazon-connect-streams/esm";

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions