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

Any reason to keep "@types/core-js" defined in "dependencies" section? It breaks AngularCompilerPlugin with TypeScript-based webpack config #712

Closed
vladimiry opened this issue Jul 15, 2018 · 2 comments

Comments

@vladimiry
Copy link

Case

Failed to compile Angular project using AngularCompilerPlugin from @ngtools/webpack module having rxdb dependency added.

I go with TypeScript-based webpack configs files, most developers don't, so they don't notice this issue. For example, Angular CLI still goes with JS based configs. I also have no tsconfig.json=>compilerOptions.skipLibCheck option enabled. So a workaround is to enable skipLibCheck compilation option, which disables declaration files checking.

Issue

node_modules/@types/core-js/index.d.ts pollutes a global declarations scope. This is ok if you add this development time dependency explicitly as a developer. But this project leaves no choice having @types/core-js defined as a runtime dependency (dependencies section).

Info

  • Environment: irrelevant
  • Adapter: irrelevant
  • Stack: (Typescript, Angular)

Here is error stack trace output:

ERROR in node_modules/@angular-devkit/core/src/utils/partially-ordered-set.d.ts(21,5): error TS2416: Property 'forEach' in type 'PartiallyOrderedSet<T>' is not assignable to the same property in base type 'Set<T>'.
  Type '(callbackfn: (value: T, value2: T, set: PartiallyOrderedSet<T>) => void, thisArg?: any) => void' is not assignable to type '(callbackfn: (value: T, value2: T, set: Set<T>) => void, thisArg?: any) => void'.
    Types of parameters 'callbackfn' and 'callbackfn' are incompatible.
      Types of parameters 'set' and 'set' are incompatible.
        Type 'PartiallyOrderedSet<T>' is not assignable to type 'Set<T>'.
          Property 'toJSON' is missing in type 'PartiallyOrderedSet<T>'.

There is such code in /node_modules/@angular-devkit/core/src/utils/partially-ordered-set.d.ts

export declare class PartiallyOrderedSet<T> implements Set<T> {
    private _items;
    protected _checkCircularDependencies(item: T, deps: Set<T>): void;
    clear(): void;
    has(item: T): boolean;
    readonly size: number;
    forEach(callbackfn: (value: T, value2: T, set: PartiallyOrderedSet<T>) => void, thisArg?: any): void;
    /**
     * Returns an iterable of [v,v] pairs for every value `v` in the set.
     */
    entries(): IterableIterator<[T, T]>;
    /**
     * Despite its name, returns an iterable of the values in the set,
     */
    keys(): IterableIterator<T>;
    /**
     * Returns an iterable of values in the set.
     */
    values(): IterableIterator<T>;
    add(item: T, deps?: (Set<T> | T[])): this;
    delete(item: T): boolean;
    [Symbol.iterator](): IterableIterator<T>;
    readonly [Symbol.toStringTag]: 'Set';
}

PartiallyOrderedSet implements the Set interface, but there is no toJSON method implemented, while node_modules/@types/core-js/index.d.ts forces toJSON to be implemented.

So is there any reason why @types/core-js is put as a runtime dependency, rather than dev dependency (devDependencies section)?

@pubkey
Copy link
Owner

pubkey commented Jul 16, 2018

Hi @vladimiry Thanks for pointing this out. I do not see a reason why we need @types/core-js in the dependencies. I can also not remember why I added it :)

@vladimiry
Copy link
Author

Thanks for a fast response. Would like to see @types/core-js moved to devDependencies section or removed then.

@pubkey pubkey closed this as completed in 93f7ade Jul 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants