Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing types field for @angular/common/locales of exports in package.json #52011

Closed
emeryao opened this issue Oct 4, 2023 · 1 comment
Closed

Comments

@emeryao
Copy link

emeryao commented Oct 4, 2023

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

common

Is this a regression?

No

Description

for now the package.json of @angular/common looks like below

./node_modules/@angular/common/package.json

{
// ...
"name": "@angular/common",
"exports": {
    // ...
    "./locales/*": {
      "default": "./locales/*.mjs"
    },
    // ...
  },
// ...
}

./src/app/app.module.ts

import { registerLocaleData } from '@angular/common';
import localeData from '@angular/common/locales/zh-Hans';

registerLocaleData(localeData);

and when I change the moduleResolution to bundler in tsconfig.json there will be an error called Could not find a declaration file for module '@angular/common/locales/zh-Hans' since the lack of a types field in the exports for ./locales/* when I manually update the package.json like below the error has gone

{
// ...
"name": "@angular/common",
"exports": {
    // ...
    "./locales/*": {
      "types": "./locales/*.d.ts",
      "default": "./locales/*.mjs"
    },
    // ...
  },
// ...
}

and finally I update the import statement to import localeData from '../../node_modules/@angular/common/locales/zh-Hans'; as a workaround without touching the file of ./node_modules/@angular/common/package.json

the types field should be added to the exports of "./locales/*" in package.json of the @angular/common package

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

Angular CLI: 16.2.4
Node: 20.8.0 (Unsupported)
Package Manager: npm 10.2.0
OS: win32 x64

Angular: 16.2.7
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
... service-worker

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1602.4
@angular-devkit/build-angular   16.2.4
@angular-devkit/core            16.2.4
@angular-devkit/schematics      16.2.4
@angular/cli                    16.2.4
@schematics/angular             16.2.4
rxjs                            7.8.1
typescript                      5.1.6
zone.js                         0.14.0

Anything else?

No response

sdedieu added a commit to sdedieu/angular that referenced this issue Oct 6, 2023
…xports in package.json

Add a types entry in the packages/common/package.json exports "./locales/*" section

Fixes angular#52011
alan-agius4 pushed a commit to sdedieu/angular that referenced this issue Oct 6, 2023
…xports in package.json

Add a types entry in the packages/common/package.json exports "./locales/*" section

Fixes angular#52011
sdedieu added a commit to sdedieu/angular that referenced this issue Oct 7, 2023
…xports in package.json

Add a types entry in the packages/common/package.json exports "./locales/*" section

Fixes angular#52011
sdedieu added a commit to sdedieu/angular that referenced this issue Oct 7, 2023
…xports in package.json

Add a types entry in the packages/common/package.json exports "./locales/*" section

Fixes angular#52011
@ngbot ngbot bot added this to the needsTriage milestone Oct 9, 2023
alan-agius4 pushed a commit to sdedieu/angular that referenced this issue Oct 10, 2023
…xports in package.json

Add a types entry in the packages/common/package.json exports "./locales/*" section

Fixes angular#52011
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Nov 11, 2023
ChellappanRajan pushed a commit to ChellappanRajan/angular that referenced this issue Jan 23, 2024
…xports in package.json (angular#52080)

Add a types entry in the packages/common/package.json exports "./locales/*" section

Fixes angular#52011

PR Close angular#52080
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants
@pkozlowski-opensource @emeryao and others