Skip to content

installing @angular/localize broke jasmine/types #48434

Closed

Description

@kondelik

Which @angular/* package(s) are the source of the bug?

localize

Is this a regression?

Yes

Description

When I install @angular/localize in newly created angular project, jasmine types (describe, it, expect, afterAll etc) are not recognized inside *.spec.ts:

To reproduce:

ng new Angular15.net
cd Angular15.net
ng add @angular/localize
# code .

image
(these error messages are in czech - see below for english error messages)

Please provide a link to a minimal reproduction of the bug

ng new Angular15.net
cd Angular15.net
ng add @angular/localize
# code .

Please provide the exception or error you saw

describe():

Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.(2593)

it():

Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.(2593)

expect():

Cannot find name 'expect'.(2304)

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 15.0.3
Node: 18.12.1
Package Manager: yarn 1.22.19
OS: win32 x64

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

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1500.3
@angular-devkit/build-angular   15.0.3
@angular-devkit/core            15.0.3
@angular-devkit/schematics      15.0.3
@schematics/angular             15.0.3
rxjs                            7.5.7
typescript                      4.8.4

Anything else?

yarn add --dev @types/jasmine@4.3.0: does not help.

yarn test: tests are executed successfully:
image

Activity

  1. kondelik commented on Dec 10, 2022

    @kondelik
    Author

    Edit: No, I did not.
    When I do it like I wrote (see below), then

    export class AppComponent {
      title = $localize`Angular15.new`;
    }

    then $localize is undefined... 😩

    Old comment:

    I just found a workaround:
    Looks like "types": [] from tsconfig.json are not overriden from tsconfig.spec.json

    open tsconfig.json and remove

    "types": [
      "@angular/localize"
    ]

    open tsconfig.app.json and check that there is:

    "types": [
      "@angular/localize"
    ]

    finally, open tsconfig.spec.json and check that there is:

    "types": [
      "jasmine",
      "@angular/localize"
    ]
  2. self-assigned this
    on Dec 12, 2022
  3. added
    area: i18nIssues related to localization and internationalization
    on Dec 12, 2022
  4. added this to the needsTriage milestone on Dec 12, 2022
  5. kondelik commented on Dec 17, 2022

    @kondelik
    Author

    Looking at PR #48502 - workaround right now is:

    main.ts; add:

    /// <reference types="@angular/localize" />
    

    and remove every mention of

    "@angular/localize"
    

    from tsconfig.json

  6. alan-agius4 commented on Dec 17, 2022

    @alan-agius4
    Contributor

    "@angular/localize" types should only be removed from the root tsconfig.json.

  7. added a commit that references this issue on Jan 4, 2023
    881ecb0
  8. added a commit that references this issue on Feb 1, 2023
    ae03aea
  9. angular-automatic-lock-bot commented on Feb 4, 2023

    @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.

  10. locked and limited conversation to collaborators on Feb 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: i18nIssues related to localization and internationalization

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions