Skip to content

$localize is not found after ng add with cli v15.0.0-next.4 and ng v15.0.0-next.5 #47677

Closed

Description

@cexbrayat

Command

add

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

14.2.5

Description

Angular v15.0.0-next.5 contains the fix from @alan-agius4 to properly add the @angular/localize polyfill in a CLI app now that the polyfills.ts file is gone. 400a6b5

The polyfill is added when running ng add, but it looks like using $localize still doesn't work.

Error: src/app/app.component.ts:9:11 - error TS2304: Cannot find name '$localize'.

9   title = $localize`i18n-next`;

Minimal Reproduction

npx @angular/[email protected] new i18n-next --defaults
cd i18n-next
npm i
ng add @angular/[email protected] --skip-confirmation

then update app.component.ts with:

title = $localize`i18n-next`;

and run:

ng extract-i18n --output-path src/locale/

The same repro using the stable release of the CLI and fwk works out of the box.

Exception or Error

Error: src/app/app.component.ts:9:11 - error TS2304: Cannot find name '$localize'.

9   title = $localize`i18n-next`;

Your Environment

Angular CLI: 15.0.0-next.4
Node: 16.17.0
Package Manager: npm 6.14.17
OS: darwin arm64

Angular: 15.0.0-next.5
... animations, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1500.0-next.4
@angular-devkit/build-angular   15.0.0-next.4
@angular-devkit/core            15.0.0-next.4
@angular-devkit/schematics      15.0.0-next.4
@angular/cli                    15.0.0-next.4
@schematics/angular             15.0.0-next.4
rxjs                            7.5.7
typescript                      4.7.4

Anything else relevant?

No response

Activity

  1. changed the title [-]$localize is not found after `ng add` with cli/ng v15.0.0-next.4[/-] [+]$localize is not found after `ng add` with cli v15.0.0-next.4 and ng v15.0.0-next.5[/+] on Oct 6, 2022
  2. self-assigned this
    on Oct 6, 2022
  3. alan-agius4 commented on Oct 6, 2022

    @alan-agius4
    Contributor

    The problem here is that while we are adding @angular/localize/init to the polyfills this is not included as part of the TypeScript compilation which caused the global $localize type to not be added.

    Therefore we'd need to add "@angular/localize/init" as a type in the TypeScript configurations.

    I am going to transfer this to the framework as this needs to be addressed by the ng-add schematic.

  4. added
    area: i18n
    on Oct 6, 2022
  5. added this to the needsTriage milestone on Oct 6, 2022
  6. added
    regression
    on Oct 6, 2022
  7. changed the title [-]$localize is not found after `ng add` with cli v15.0.0-next.4 and ng v15.0.0-next.5[/-] [+]`$localize` is not found after `ng add` with cli v15.0.0-next.4 and ng v15.0.0-next.5[/+] on Oct 6, 2022
  8. 3 remaining items

  9. added a commit that references this issue on Oct 17, 2022
    b6fd814
  10. angular-automatic-lock-bot commented on Nov 17, 2022

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  11. locked and limited conversation to collaborators on Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: i18nbugregression

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions