You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
Activity
[@angular/localize] add new $localize definitions (DefinitelyTyped#46160
[@angular/localize] add new $localize definitions (DefinitelyTyped#46160
peterblazejewicz commentedon Jul 17, 2020
AS asked on the PR, can you explain how and what problem it would solve?
sorohan commentedon Jul 17, 2020
Thanks for your help.
Angular provides a global template string function
$localize, which is added to the global by including@angular/localize/initto an application's polyfills.This does 2 things, it declares the
$localizetype so that typescript knows about it, but it is also effectful, and adds$localizeto the globals.That works for applications but in order to compile and publish a library which makes use of
$localizeyou need to somehow declare the$localizeglobal 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
importthat 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.peterblazejewicz commentedon Jul 18, 2020
@sorohan kudos!