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

Bug(transloco-preload-langs): requestIdleCallback global type conflict #510

Closed
1 task done
nicholas-ochoa opened this issue Sep 30, 2021 · 2 comments
Closed
1 task done
Assignees
Labels
bug Something isn't working

Comments

@nicholas-ochoa
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Which Transloco package(s) are the source of the bug?

Preload Langs

Is this a regression?

No

Current behavior

Receiving an error when compiling an application that references @ngneat/transloco-preload-langs:

Error: ../node_modules/.pnpm/@[email protected]_510e379a0c10b7b012326159b0495067/node_modules/@ngneat/transloco-preload-langs/lib/preload-langs.module.d.ts:10:9 - error TS2717: Subsequent property declarations must have the same type.  Property 'requestIdleCallback' must be of type '(callback: IdleRequestCallback, options?: IdleRequestOptions) => number', but here has type '(cb: IdleCallback) => number'.

10         requestIdleCallback: (cb: IdleCallback) => number;
           ~~~~~~~~~~~~~~~~~~~

  ../node_modules/.pnpm/[email protected]/node_modules/typescript/lib/lib.dom.d.ts:17326:5
    17326     requestIdleCallback(callback: IdleRequestCallback, options?: IdleRequestOptions): number;
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    'requestIdleCallback' was also declared here.

It appears that @ngneat/transloco-preload-langs is defining requestIdleCallback in lib/preload-langs.module.d.ts which is conflicting with the type provided in typescript 4.4.3 lib/lib.dom.d.ts. Here is the type in question:

declare global {
    interface Window {
        requestIdleCallback: (cb: IdleCallback) => number;
        cancelIdleCallback: (id: number) => void;
    }
}

If I comment out the requestIdleCallback line in lib/preload-langs.module.d.ts I am able to compile and use my application normally. I'm not sure if this is a type that was only recently added to this package, but I've noticed this problem only in the last few weeks.

Expected behavior

There should be no compilation errors or type conflicts

Please provide a link to a minimal reproduction of the bug

None

Transloco Config

No response

Please provide the environment you discovered this bug in

Transloco: 3.0.0
Angular: 12.2.7
Node: 14.17.5
Package Manager: PNPM 6.16.0
OS: Windows 10 Pro
TypeScript: 4.4.3

Browser

N/A

Additional context

A similar issue seems to have occurred last year, but was fixed in a 3rd party module instead: #291

I would like to make a pull request for this bug

No

@shaharkazaz
Copy link
Collaborator

@nicholas-ochoa That's something new added in typescript v4.4, I'll take care of it.

@shaharkazaz shaharkazaz added the bug Something isn't working label Sep 30, 2021
@shaharkazaz shaharkazaz self-assigned this Sep 30, 2021
@nicholas-ochoa
Copy link
Author

Awesome, thanks for the fast response and turnaround!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants