Skip to content

Ivy: Generic type 'ɵɵBaseDef<T>' requires 1 type argument(s). #31160

Closed

Description

@kccsf

🐞 bug report

Affected Package

@angular/material
@angular/flex-layout

Is this a regression?

Yes - works prior to building with Ivy.

Description

Building with Ivy causes .d.ts files to be modified. As part of those modifications, the following line is added:
`static ngBaseDef: ɵngcc0.ɵɵBaseDef;`

This causes the build to fail. Switching 'enableIvy' back to false still results in a broken build due to the .d.ts file modifications (although the 'WARNING' lines disappear).

🔬 Minimal Reproduction

https://github.com/kccsf/IvyIssue

🔥 Exception or Error



WARNING in Unknown member type: "[key: string]: (data: any) => void;

WARNING in Unknown member type: "[key: string]: (data: any) => void;

WARNING in Unknown member type: "[key: string]: (data: any) => void;

ERROR in node_modules/@angular/flex-layout/extended/typings/class/class.d.ts(30,23): error TS2314: Generic type 'ɵɵBaseDef' requires 1 type argument(s).
node_modules/@angular/flex-layout/extended/typings/img-src/img-src.d.ts(38,23): error TS2314: Generic type 'ɵɵBaseDef' requires 1 type argument(s).
node_modules/@angular/flex-layout/flex/typings/flex/flex.d.ts(50,23): error TS2314: Generic type 'ɵɵBaseDef' requires 1 type argument(s).
node_modules/@angular/flex-layout/grid/typings/align-columns/align-columns.d.ts(28,23): error TS2314: Generic type 'ɵɵBaseDef' requires 1 type argument(s).
node_modules/@angular/flex-layout/grid/typings/align-rows/align-rows.d.ts(28,23): error TS2314: Generic type 'ɵɵBaseDef' requires 1 type argument(s).
node_modules/@angular/flex-layout/grid/typings/areas/areas.d.ts(31,23): error TS2314: Generic type 'ɵɵBaseDef' requires 1 type argument(s).
node_modules/@angular/flex-layout/grid/typings/auto/auto.d.ts(31,23): error TS2314: Generic type 'ɵɵBaseDef' requires 1 type argument(s).
node_modules/@angular/flex-layout/grid/typings/columns/columns.d.ts(32,23): error TS2314: Generic type 'ɵɵBaseDef' requires 1 type argument(s).
node_modules/@angular/flex-layout/grid/typings/gap/gap.d.ts(31,23): error TS2314: Generic type 'ɵɵBaseDef' requires 1 type argument(s).
node_modules/@angular/flex-layout/grid/typings/rows/rows.d.ts(32,23): error TS2314: Generic type 'ɵɵBaseDef' requires 1 type argument(s).
node_modules/@angular/material/menu/typings/menu.d.ts(161,23): error TS2314: Generic type 'ɵɵBaseDef' requires 1 type argument(s).

🌍 Your Environment

Angular Version:



Angular CLI: 8.1.0-beta.2
Node: 10.15.3
OS: win32 x64
Angular: 8.1.0-next.3
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.801.0-beta.2
@angular-devkit/build-angular     0.801.0-beta.2
@angular-devkit/build-optimizer   0.801.0-beta.2
@angular-devkit/build-webpack     0.801.0-beta.2
@angular-devkit/core              8.1.0-beta.2
@angular-devkit/schematics        8.1.0-beta.2
@angular/cdk                      8.0.0
@angular/cli                      8.1.0-beta.2
@angular/flex-layout              8.0.0-beta.26
@angular/material                 8.0.1
@ngtools/webpack                  8.1.0-beta.2
@schematics/angular               8.1.0-beta.2
@schematics/update                0.801.0-beta.2
rxjs                              6.3.3
typescript                        3.4.5
webpack                           4.34.0

Anything else relevant?

Activity

  1. magnattic commented on Jun 20, 2019

    @magnattic

    This seems to happen when a Directive inherits from another class (that doesn't have any metadata).

    I have the same problem when I compile my library that uses angular-l10n:
    robisim74/angular-l10n#253

    The base class that causes the problem is this one:
    https://github.com/robisim74/angular-l10n/blob/master/src/models/base-directive.ts

  2. magnattic commented on Jun 20, 2019

    @magnattic

    Apparently this is a regression in 8.1.0, it works fine with 8.0.0 and enableIvy: true.

    See the discussion on robisim74/angular-l10n#253

  3. added this to the needsTriage milestone on Jun 20, 2019
  4. self-assigned this
    on Jun 22, 2019
  5. modified the milestones: needsTriage, Backlog on Jun 22, 2019
  6. 29 remaining items

  7. willkara commented on Jul 30, 2019

    @willkara

    Looks like this is still broken by default when running ng new App and then enabling Ivy.

    I wasn't able to fix it by making the cli/compiler version changes.

    {
      "name": "*************",
      "version": "0.0.0",
      "scripts": {
        "ng": "ng",
        "start": "ng serve",
        "build": "ng build",
        "test": "ng test",
        "lint": "ng lint",
        "e2e": "ng e2e"
      },
      "private": true,
      "dependencies": {
        "@angular/animations": "^8.1.3",
        "@angular/cdk": "^8.1.2",
        "@angular/common": "~8.1.1",
        "@angular/compiler": "~8.1.1",
        "@angular/core": "~8.1.1",
        "@angular/forms": "~8.1.1",
        "@angular/material": "^8.1.2",
        "@angular/platform-browser": "~8.1.1",
        "@angular/platform-browser-dynamic": "~8.1.1",
        "@angular/router": "~8.1.1",
        "moment": "^2.24.0",
        "rxjs": "~6.4.0",
        "tslib": "^1.9.0",
        "zone.js": "~0.9.1"
      },
      "devDependencies": {
        "@angular-devkit/build-angular": "~0.801.1",
        "@angular/cli": "~8.2.0-next.0",
        "@angular/compiler-cli": "~8.2.0-next.0",
        "@angular/language-service": "~8.1.1",
        "@types/jasmine": "~3.3.8",
        "@types/jasminewd2": "~2.0.3",
        "@types/node": "~8.9.4",
        "codelyzer": "^5.0.0",
        "jasmine-core": "~3.4.0",
        "jasmine-spec-reporter": "~4.2.1",
        "karma": "~4.1.0",
        "karma-chrome-launcher": "~2.2.0",
        "karma-coverage-istanbul-reporter": "~2.0.1",
        "karma-jasmine": "~2.0.1",
        "karma-jasmine-html-reporter": "^1.4.0",
        "protractor": "~5.4.0",
        "ts-node": "~7.0.0",
        "tslint": "~5.15.0",
        "typescript": "~3.4.3"
      }
    }
    

    tsconfig.json

      "angularCompilerOptions": {
        "fullTemplateTypeCheck": true,
        "strictInjectionParameters": true
      }
    

    tsconfig.app.json

      "angularCompilerOptions": {
        "enableIvy": true
      }
    

    Gives me the error:
    An unhandled exception occurred: Object prototype may only be an Object or null: undefined

    Is there an ETA on when it'll be fixed on a stable version?

  8. mahdiprog commented on Aug 26, 2019

    @mahdiprog

    same here

  9. benelliott commented on Sep 26, 2019

    @benelliott
    Contributor

    @petebacondarwin I'm still seeing this bug on 9.0.0-next.8, with type errors springing up for .d.ts entries for abstract superclasses (without metadata) for concrete components. Would you like me to try to create a reproduction or are you aware of the issue?

  10. JoostK commented on Sep 26, 2019

    @JoostK
    Member

    @benelliott we are aware of that issue, it's a slight variation of the one reported here. A compilation error occurs for base classes without @Directive() decorator that require generic type arguments themselves.

    You can probably workaround that issue by adding the @Directive() decorator to the base class, which ensures that an ngDirectiveDef is produced instead of the ngBaseDef; the former does not suffer from the same bug.

  11. benelliott commented on Sep 26, 2019

    @benelliott
    Contributor

    @JoostK Thanks - is there a separate issue I can follow for that one?

    The typedefs are coming from an internal library - AFAIK selectorless directives are only supported on v9+ so I couldn't add that to my library without breaking compat for v8 right?

  12. JoostK commented on Sep 26, 2019

    @JoostK
    Member

    @benelliott There's no github issue at the moment. The plan is to get rid of ngBaseDef altogether, so no effort has been put into fixing this issue. Feel free to open an issue for tracking purposes, if you like.

    Your point regarding backwards compatibility is a valid concern for which I don't know the answer. I suspect it may indeed break, as you're afraid of.

    As an alternative, you could insert a default type for the generic type parameter:

    export class BaseComp<T> {}

    becomes

    export class BaseComp<T=unknown> {}

    This is not ideal and should just be considered as a temporary workaround.

  13. benelliott commented on Sep 27, 2019

    @benelliott
    Contributor

    @JoostK Thanks. I think this won't work in my case as the generic is bounded by an extends, ie I can't do BaseComp<T extends U = unknown>.

  14. benelliott commented on Oct 3, 2019

    @benelliott
    Contributor

    For anyone else who has the same issue as me - I worked around it by adding a Directive with a dummy selector (not empty, but something that obviously shouldn't be used) to my abstract classes and then declaring them in my modules, inspired by this commit in @angular/components:

    angular/components@8c98013

  15. xboysms commented on Oct 21, 2019

    @xboysms

    ok, please undo package-lock.json file
    then npm install
    should work, it is working fine for me

  16. abadakhshan commented on Oct 24, 2019

    @abadakhshan
    Contributor

    I still have this problem

    node_modules/narik-app-core/lib/base/narik-detail-form.d.ts:61:40 - error TS2314: Generic type 'NarikDetailForm<TE>' requires 1 type argument(s).
    
    61     static ngBaseDef: ɵngcc0.ɵɵBaseDef<NarikDetailForm>;
    
    "dependencies": {
        "@angular/animations": "~9.0.0-next.12",
        "@angular/cdk": "^8.0.0",
        "@angular/common": "~9.0.0-next.12",
        "@angular/compiler": "~9.0.0-next.12",
        "@angular/core": "~9.0.0-next.12",
        "@angular/flex-layout": "^8.0.0-beta.26",
        "@angular/forms": "~9.0.0-next.12",
        "@angular/material": "^8.0.0",
        "@angular/platform-browser": "~9.0.0-next.12",
        "@angular/platform-browser-dynamic": "~9.0.0-next.12"...
    ...
    }
    
    "devDependencies": {
        "@angular-builders/custom-webpack": "^8.0.2",
        "@angular-devkit/build-angular": "~0.900.0-next.15",
        "@angular/cli": "~9.0.0-next.15",
        "@angular/compiler-cli": "~9.0.0-next.12",
        "@angular/language-service": "~9.0.0-next.12",
    ....
    }
    
  17. gkalpak commented on Oct 24, 2019

    @gkalpak
    Member

    These errors will likely be fixed by #33264.

  18. abadakhshan commented on Oct 28, 2019

    @abadakhshan
    Contributor

    Thank you @gkalpak
    It was fixed by "9.0.0-next.14"

  19. angular-automatic-lock-bot commented on Nov 28, 2019

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

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions