Skip to content

[request] @angular/localize #46160

Closed
Closed

Description

@sorohan

@angular/localize/init declares the global $localize.

The types are provided by angular, but they cannot be used when publishing a library making use of $localize. See this comment. I think the best solution is to have them typed here.

I've already confirmed that this will resolve the issue with using $localize in angular libraries. I'll make a PR for this as well.

Activity

  1. peterblazejewicz commented on Jul 17, 2020

    @peterblazejewicz
    Member

    I've already confirmed that this will resolve the issue with using $localize in angular libraries. I'll make a PR for this as well.

    AS asked on the PR, can you explain how and what problem it would solve?

  2. sorohan commented on Jul 17, 2020

    @sorohan
    Author

    Thanks for your help.

    Angular provides a global template string function $localize, which is added to the global by including @angular/localize/init to an application's polyfills.

    This does 2 things, it declares the $localize type so that typescript knows about it, but it is also effectful, and adds $localize to the globals.

    That works for applications but in order to compile and publish a library which makes use of $localize you need to somehow declare the $localize global for typescript.

    My understanding is that the best way for an NPM package to declare a global that's expected to be there without the need to import that package is to use DT. There's a good chance I'm wrong about that, so any advice on this would be appreciated. I've asked for advice from the angular team here too.

  3. peterblazejewicz commented on Jul 18, 2020

    @peterblazejewicz
    Member

    @sorohan kudos!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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