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

Ivy: Debug assert: importing a Reference to non-declaration? #34837

Closed
marcj opened this issue Jan 17, 2020 · 6 comments
Closed

Ivy: Debug assert: importing a Reference to non-declaration? #34837

marcj opened this issue Jan 17, 2020 · 6 comments
Assignees
Labels
area: compiler Issues related to `ngc`, Angular's template compiler freq1: low state: has PR type: bug/fix
Milestone

Comments

@marcj
Copy link

marcj commented Jan 17, 2020

🐞 bug report

Is this a regression?

Yes, worked in non-ivy.

Description

When importing and using a third party file that contains only interfaces/types I get an error when building in production mode. In development mode everything works fine.

Debug assert: importing a Reference to non-declaration?

throw new Error('Debug assert: importing a Reference to non-declaration?');

🔬 Minimal Reproduction

I still work on that. I have it in a rather big code base, so this might take some time.

🔥 Exception or Error

ERROR in Error: Debug assert: importing a Reference to non-declaration?
    at AbsoluteModuleStrategy.emit (/Users/marc/bude/deepkit/packages/deepkit/node_modules/@angular/compiler-cli/src/ngtsc/imports/src/emitter.js:117:23)
    at ReferenceEmitter.emit (/Users/marc/bude/deepkit/packages/deepkit/node_modules/@angular/compiler-cli/src/ngtsc/imports/src/emitter.js:42:44)
    at TypeCheckFile.Environment.referenceType (/Users/marc/bude/deepkit/packages/deepkit/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/environment.js:208:42)
    at TypeEmitter.emitReference (/Users/marc/bude/deepkit/packages/deepkit/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/environment.js:216:63)
    at TypeEmitter.emitTypeReference (/Users/marc/bude/deepkit/packages/deepkit/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_emitter.js:117:40)
    at Object.visitTypeReferenceNode (/Users/marc/bude/deepkit/packages/deepkit/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_emitter.js:93:72)
    at visitTypeNode (/Users/marc/bude/deepkit/packages/deepkit/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_emitter.js:130:28)
    at TypeEmitter.emitType (/Users/marc/bude/deepkit/packages/deepkit/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_emitter.js:92:20)
    at /Users/marc/bude/deepkit/packages/deepkit/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_parameter_emitter.js:57:79
    at Array.map (<anonymous>)
    at TypeParameterEmitter.emit (/Users/marc/bude/deepkit/packages/deepkit/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_parameter_emitter.js:56:40)
    at TypeCheckFile.Environment.emitTypeParameters (/Users/marc/bude/deepkit/packages/deepkit/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/environment.js:216:28)
    at TypeCheckFile.Environment.typeCtorFor (/Users/marc/bude/deepkit/packages/deepkit/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/environment.js:93:39)
    at tcbCallTypeCtor (/Users/marc/bude/deepkit/packages/deepkit/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_check_block.js:1276:32)
    at TcbDirectiveOp.execute (/Users/marc/bude/deepkit/packages/deepkit/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_check_block.js:332:28)
    at Scope.executeOp (/Users/marc/bude/deepkit/packages/deepkit/node_modules/@angular/compiler-cli/src/ngtsc/typecheck/src/type_check_block.js:884:26)

When I print all the arguments via

console.log('ref', ref, context, importMode);
throw new Error('Debug assert: importing a Reference to non-declaration?');

in that method I get:

ef Reference {
  node: NodeObject {
    pos: 181,
    end: 253,
    flags: 0,
    modifierFlagsCache: 536870913,
    transformFlags: 536870913,
    parent: SourceFileObject {
      pos: 0,
      end: 9926,
      flags: 0,
      modifierFlagsCache: 0,
      transformFlags: 536870913,
      parent: undefined,
      kind: 285,
      text: 'import {JSONEntity} from "./core";\n' +
        'import {CollectionPaginationEvent, CollectionSort, FilterParameters} from "./collection";\n' +
        'import {PropertySchemaSerialized} from "@marcj/marshal";\n' +
        '\n' +
        'export interface IdInterface {\n' +
        '    id: string;\n' +
        '\n' +
        '    version: number;\n' +
        '}\n' +
        '\n' +
        'export interface EntityPatches {\n' +
        '    [path: string]: any;\n' +
        '}\n' +
        '\n' +
        'export interface ExchangeEntityBase {\n' +
        '    id: string;\n' +
        '    version: number;\n' +
        '}\n' +
        '\n' +
        'export interface ExchangeEntityAdd extends ExchangeEntityBase {\n' +
        "    type: 'add';\n" +
        '    item: any;\n' +
        '}\n' +
        '\n' +
        'export interface ExchangeEntityRemove extends ExchangeEntityBase {\n' +
        "    type: 'remove';\n" +
        '}\n' +
        '\n' +
        'export interface ExchangeEntityRemoveMany {\n' +
        "    type: 'removeMany';\n" +
        '    ids: string[];\n' +
        '}\n' +
        '\n' +
        'export interface ExchangeEntityUpdate extends ExchangeEntityBase {\n' +
        "    type: 'update';\n" +
        '    item: any;\n' +
        '}\n' +
        '\n' +
        'export interface ExchangeEntityPatch extends ExchangeEntityBase {\n' +
        "    type: 'patch';\n" +
        '    patch: EntityPatches;\n' +
        '    item: any;\n' +
        '}\n' +
        '\n' +
        'export type ExchangeEntity = ExchangeEntityAdd | ExchangeEntityRemove | ExchangeEntityUpdate | ExchangeEntityPatch | ExchangeEntityRemoveMany;\n' +
        '\n' +
        'export interface ClientPushMessage {\n' +
        "    name: 'push-message/reply';\n" +
        '    replyId: number;\n' +
        '    data: any;\n' +
        '}\n' +
        '\n' +
        'export interface ClientMessageId {\n' +
        '    id: number;\n' +
        '}\n' +
        '\n' +
        'export interface ClientMessagePeerRegisterController {\n' +
        "    name: 'peerController/register';\n" +
        '    controllerName: string;\n' +
        '}\n' +
        '\n' +
        '//from client to peer\n' +
        'export interface ClientMessagePeerMessage {\n' +
        "    name: 'peerController/message';\n" +
        '    controllerName: string;\n' +
        '    clientId: string;\n' +
        '    data: ServerMessageResult;\n' +
        '}\n' +
        '\n' +
        'export interface ClientMessagePeerEndMessage {\n' +
        "    name: 'peerUser/end';\n" +
        '}\n' +
        '\n' +
        'export interface ClientMessagePeerUnRegisterController {\n' +
        "    name: 'peerController/unregister';\n" +
        '    controllerName: string;\n' +
        '}\n' +
        '\n' +
        'export interface ClientMessageActionTypes {\n' +
        "    name: 'actionTypes';\n" +
        '    controller: string;\n' +
        '    action: string;\n' +
        '    timeout: number;\n' +
        '}\n' +
        '\n' +
        'export interface ClientMessageAuthorize {\n' +
        "    name: 'authenticate';\n" +
        '    token: any;\n' +
        '}\n' +
        '\n' +
        'export interface ClientMessageAction {\n' +
        "    name: 'action';\n" +
        '    controller: string;\n' +
        '    action: string;\n' +
        '    args: any[];\n' +
        '    timeout: number;\n' +
        '}\n' +
        '\n' +
        'export interface ClientPeerMessageAction {\n' +
        "    name: 'peerMessage';\n" +
        '    controller: string;\n' +
        '    message: any;\n' +
        '    timeout: number;\n' +
        '}\n' +
        '\n' +
        'export interface ClientMessageEntityUnsubscribe {\n' +
        "    name: 'entity/unsubscribe';\n" +
        '    forId: number;\n' +
        '}\n' +
        '\n' +
        'export interface ClientMessageSubjectUnsubscribe {\n' +
        "    name: 'subject/unsubscribe';\n" +
        '    forId: number;\n' +
        '}\n' +
        '\n' +
        'export interface ClientMessageCollectionUnsubscribe {\n' +
        "    name: 'collection/unsubscribe';\n" +
        '    forId: number;\n' +
        '}\n' +
        '\n' +
        'export interface ClientMessageCollectionPagination {\n' +
        "    name: 'collection/pagination';\n" +
        '    forId: number;\n' +
        '    page: number;\n' +
        '    itemsPerPage: number;\n' +
        '    parameters: FilterParameters;\n' +
        "    sort: {field: string, direction: 'asc' | 'desc'}[];\n" +
        '}\n' +
        '\n' +
        'export interface ClientMessageObservableSubscribe {\n' +
        "    name: 'observable/subscribe';\n" +
        '    forId: number;\n' +
        '    subscribeId: number;\n' +
        '}\n' +
        '\n' +
        'export interface ClientMessageObservableUnsubscribe {\n' +
        "    name: 'observable/unsubscribe';\n" +
        '    forId: number;\n' +
        '    subscribeId: number;\n' +
        '}\n' +
        '\n' +
        'export type ClientMessageWithoutId = ClientPushMessage\n' +
        '    | ClientMessagePeerUnRegisterController\n' +
        '    | ClientMessagePeerRegisterController\n' +
        '    | ClientMessageCollectionPagination\n' +
        '    | ClientMessagePeerMessage\n' +
        '    | ClientMessagePeerEndMessage\n' +
        '    | ClientMessageActionTypes\n' +
        '    | ClientMessageAuthorize\n' +
        '    | ClientMessageAction\n' +
        '    | ClientMessageEntityUnsubscribe\n' +
        '    | ClientMessageObservableSubscribe\n' +
        '    | ClientMessageObservableUnsubscribe\n' +
        '    | ClientMessageCollectionUnsubscribe\n' +
        '    | ClientMessageSubjectUnsubscribe\n' +
        '    | ClientPeerMessageAction;\n' +
        '\n' +
        'export type ClientMessageAll = (ClientMessageWithoutId & ClientMessageId);\n' +
        '\n' +
        'export interface MessageEntityBase {\n' +
        '    entityName: string;\n' +
        '    id: string;\n' +
        '    version: number;\n' +
        '}\n' +
        '\n' +
        'export interface ServerMessageEntityRemove extends MessageEntityBase {\n' +
        "    type: 'entity/remove';\n" +
        '}\n' +
        '\n' +
        'export interface ServerMessageEntityRemoveMany {\n' +
        '    entityName: string;\n' +
        "    type: 'entity/removeMany';\n" +
        '    ids: string[];\n' +
        '}\n' +
        '\n' +
        'export interface ServerMessageEntityUpdate extends MessageEntityBase {\n' +
        "    type: 'entity/update';\n" +
        '    data: any;\n' +
        '}\n' +
        '\n' +
        'export interface ServerMessageEntityPatch extends MessageEntityBase {\n' +
        "    type: 'entity/patch';\n" +
        '    patch: EntityPatches;\n' +
        '}\n' +
        '\n' +
        'export type ServerMessageEntity = ServerMessageEntityRemove | ServerMessageEntityRemoveMany | ServerMessageEntityUpdate | ServerMessageEntityPatch;\n' +
        '\n' +
        'export interface CollectionStreamSet {\n' +
        "    type: 'set';\n" +
        '    items: IdInterface[];\n' +
        '    total: number;\n' +
        '}\n' +
        '\n' +
        'export interface CollectionStreamSort {\n' +
        "    type: 'sort';\n" +
        '    ids: string[];\n' +
        '}\n' +
        '\n' +
        'export interface CollectionStreamAdd {\n' +
        "    type: 'add';\n" +
        '    item: IdInterface;\n' +
        '}\n' +
        '\n' +
        'export interface CollectionStreamBatchStart {\n' +
        "    type: 'batch/start';\n" +
        '}\n' +
        '\n' +
        'export interface CollectionStreamBatchEnd {\n' +
        "    type: 'batch/end';\n" +
        '}\n' +
        '\n' +
        'export interface CollectionStreamReady {\n' +
        "    type: 'ready';\n" +
        '}\n' +
        '\n' +
        'export interface CollectionStreamRemove {\n' +
        "    type: 'remove';\n" +
        '    id: string;\n' +
        '}\n' +
        '\n' +
        'export interface CollectionStreamRemoveMany {\n' +
        "    type: 'removeMany';\n" +
        '    ids: string[];\n' +
        '}\n' +
        '\n' +
        'export interface StreamFileSet {\n' +
        "    type: 'set';\n" +
        '    path: string;\n' +
        '    version: number;\n' +
        '}\n' +
        '\n' +
        'export interface StreamFileAppend {\n' +
        "    type: 'append';\n" +
        '    path: string;\n' +
        '    version: number;\n' +
        '    content: any;\n' +
        '    size: number;\n' +
        '}\n' +
        '\n' +
        'export interface StreamFileRemove {\n' +
        "    type: 'remove';\n" +
        '    path: string;\n' +
        '}\n' +
        '\n' +
        'export interface CollectionStreamPagination {\n' +
        "    type: 'pagination';\n" +
        '    event: CollectionPaginationEvent;\n' +
        '}\n' +
        '\n' +
        'export type CollectionStream =\n' +
        '    CollectionStreamBatchStart\n' +
        '    | CollectionStreamBatchEnd\n' +
        '    | CollectionStreamPagination\n' +
        '    | CollectionStreamSet\n' +
        '    | CollectionStreamSort\n' +
        '    | CollectionStreamAdd\n' +
        '    | CollectionStreamRemove\n' +
        '    | CollectionStreamRemoveMany\n' +
        '    | CollectionStreamReady;\n' +
        '\n' +
        'export type StreamFileResult = StreamFileSet | StreamFileAppend | StreamFileRemove;\n' +
        '\n' +
        'export interface ServerMessageTypeJson {\n' +
        "    type: 'type';\n" +
        '    id: number;\n' +
        "    returnType: 'json';\n" +
        '}\n' +
        '\n' +
        'export interface ServerMessageTypeCollection {\n' +
        "    type: 'type';\n" +
        '    id: number;\n' +
        "    returnType: 'collection';\n" +
        '    pagination: {\n' +
        '        active: boolean,\n' +
        '        itemsPerPage: number,\n' +
        '        page: number,\n' +
        '        total: number,\n' +
        '        sort: CollectionSort[],\n' +
        '        parameters: FilterParameters,\n' +
        '    };\n' +
        '    entityName: string;\n' +
        '}\n' +
        '\n' +
        'export interface ServerMessageTypeObservable {\n' +
        "    type: 'type';\n" +
        "    returnType: 'observable';\n" +
        '    id: number;\n' +
        '}\n' +
        '\n' +
        'export interface ServerMessageTypeEntity<T extends IdInterface> {\n' +
        "    type: 'type';\n" +
        "    returnType: 'entity';\n" +
        '    id: number;\n' +
        '    entityName?: string;\n' +
        '    item?: JSONEntity<T>;\n' +
        '}\n' +
        '\n' +
        'export interface ServerMessageTypeSubject {\n' +
        "    type: 'type';\n" +
        "    returnType: 'subject';\n" +
        '    id: number;\n' +
        '    encoding: PropertySchemaSerialized;\n' +
        '    data: any;\n' +
        '}\n' +
        '\n' +
        'export type ServerMessageType = ServerMessageTypeJson | ServerMessageTypeCollection | ServerMessageTypeObservable\n' +
        '    | ServerMessageTypeEntity<IdInterface> | ServerMessageTypeSubject;\n' +
        '\n' +
        'export interface ServerMessageNextJson {\n' +
        "    type: 'next/json';\n" +
        '    id: number;\n' +
        '    encoding: PropertySchemaSerialized;\n' +
        '    next: any;\n' +
        '}\n' +
        '\n' +
        'export interface ServerPushMessageMessage {\n' +
        "    type: 'push-message';\n" +
        '    replyId: number;\n' +
        '    next: any;\n' +
        '}\n' +
        '\n' +
        'export interface ServerMessageNextObservable {\n' +
        "    type: 'next/observable';\n" +
        '    id: number;\n' +
        '    encoding: PropertySchemaSerialized;\n' +
        '    next: any;\n' +
        '    subscribeId: number;\n' +
        '}\n' +
        '\n' +
        'export interface ServerMessageNextSubject {\n' +
        "    type: 'next/subject';\n" +
        '    id: number;\n' +
        '    encoding: PropertySchemaSerialized;\n' +
        '    next: any;\n' +
        '}\n' +
        '\n' +
        'export interface ServerMessageAppendSubject {\n' +
        "    type: 'append/subject';\n" +
        '    id: number;\n' +
        '    encoding: PropertySchemaSerialized;\n' +
        '    append: any;\n' +
        '}\n' +
        '\n' +
        'export interface ServerMessageNextCollection {\n' +
        "    type: 'next/collection';\n" +
        '    id: number;\n' +
        '    next: CollectionStream;\n' +
        '}\n' +
        '\n' +
        'export type ServerMessageNext = ServerPushMessageMessage\n' +
        '    | ServerMessageNextJson\n' +
        '    | ServerMessageNextObservable\n' +
        '    | ServerMessageNextCollection\n' +
        '    | ServerMessageNextSubject\n' +
        '    | ServerMessageAppendSubject;\n' +
        '\n' +
        'export interface ServerMessageAck {\n' +
        "    type: 'ack';\n" +
        '    id: number;\n' +
        '}\n' +
        '\n' +
        'export interface ServerMessageCompleteGeneral {\n' +
        "    type: 'complete';\n" +
        '    id: number;\n' +
        '}\n' +
        '\n' +
        'export interface ServerMessageCompleteObservable {\n' +
        "    type: 'complete/observable';\n" +
        '    id: number;\n' +
        '    subscribeId: number;\n' +
        '}\n' +
        '\n' +
        'export type ServerMessageComplete = ServerMessageAck | ServerMessageCompleteGeneral | ServerMessageCompleteObservable;\n' +
        '\n' +
        'export interface ServerMessageErrorGeneral {\n' +
        "    type: 'error';\n" +
        '    id: number;\n' +
        '    error: any;\n' +
        '    stack: any;\n' +
        "    entityName: string | '@error:default';\n" +
        '    code?: string;\n' +
        '}\n' +
        '\n' +
        'export interface ServerMessageErrorObservable {\n' +
        "    type: 'error/observable';\n" +
        '    id: number;\n' +
        '    error: any;\n' +
        '    stack: any;\n' +
        "    entityName: string | '@error:default';\n" +
        '    subscribeId: number;\n' +
        '}\n' +
        '\n' +
        'export type ServerMessageError = ServerMessageErrorGeneral | ServerMessageErrorObservable;\n' +
        '\n' +
        'export interface ServerMessageAuthorize {\n' +
        "    type: 'authenticate/result';\n" +
        '    id: number;\n' +
        '    result: boolean;\n' +
        '}\n' +
        '\n' +
        "export type ServerMessageActionTypeNames = 'Entity' | 'Object' | 'Any' | 'Plain' | 'String' | 'Date' | 'Number' | 'Boolean' | 'undefined';\n" +
        '\n' +
        'export interface ServerMessageActionTypes {\n' +
        "    type: 'actionTypes/result';\n" +
        '    id: number;\n' +
        '    parameters: PropertySchemaSerialized[];\n' +
        '}\n' +
        '\n' +
        'export type ServerMessageResult = ServerMessageActionTypes | ServerMessageAuthorize | ServerMessageType\n' +
        '    | ServerMessageNext | ServerMessageComplete | ServerMessageError;\n' +
        '\n' +
        'export interface ServerMessageChannel {\n' +
        "    type: 'channel';\n" +
        '    name: string;\n' +
        '    data: any;\n' +
        '}\n' +
        '\n' +
        '/**\n' +
        ' * A peer message, from server to client wrapping a message sent from\n' +
        ' * the peer controller.\n' +
        ' */\n' +
        'export interface ServerMessagePeerChannelMessage {\n' +
        '    id: number;\n' +
        "    type: 'peerController/message';\n" +
        '    clientId: string;\n' +
        '    data: ClientMessageAll;\n' +
        '}\n' +
        '\n' +
        '\n' +
        'export type ServerMessageAll = ServerMessageResult | ServerMessagePeerChannelMessage | ServerMessageChannel | ServerMessageEntity;\n',
      bindDiagnostics: [],
      bindSuggestionDiagnostics: undefined,
      languageVersion: 4,
      fileName: '/Users/marc/bude/deepkit/packages/deepkit/node_modules/@marcj/glut-core/src/contract.ts',
      languageVariant: 0,
      isDeclarationFile: false,
      scriptKind: 3,
      pragmas: Map {},
      checkJsDirective: undefined,
      referencedFiles: [],
      typeReferenceDirectives: [],
      libReferenceDirectives: [],
      amdDependencies: [],
      hasNoDefaultLib: false,
      statements: [Array],
      endOfFileToken: [TokenObject],
      externalModuleIndicator: [NodeObject],
      nodeCount: 1085,
      identifierCount: 354,
      identifiers: [Map],
      parseDiagnostics: [],
      path: '/Users/marc/bude/deepkit/packages/deepkit/node_modules/@marcj/glut-core/src/contract.ts',
      resolvedPath: '/Users/marc/bude/deepkit/packages/deepkit/node_modules/@marcj/glut-core/src/contract.ts',
      originalFileName: '/Users/marc/bude/deepkit/packages/deepkit/node_modules/@marcj/glut-core/src/contract.ts',
      imports: [Array],
      moduleAugmentations: [],
      ambientModuleNames: [],
      resolvedModules: [Map],
      symbol: [SymbolObject],
      locals: [Map],
      nextContainer: [Circular],
      symbolCount: 340,
      classifiableNames: [Map],
      id: 39647
    },
    kind: 242,
    decorators: undefined,
    modifiers: [ [TokenObject], pos: 181, end: 189, transformFlags: 536870912 ],
    name: IdentifierObject {
      pos: 199,
      end: 211,
      flags: 0,
      modifierFlagsCache: 0,
      transformFlags: 536870912,
      parent: [Circular],
      escapedText: 'IdInterface',
      flowNode: [Object]
    },
    typeParameters: undefined,
    heritageClauses: undefined,
    members: [
      [NodeObject],
      [NodeObject],
      pos: 213,
      end: 251,
      transformFlags: 536870913
    ],
    symbol: SymbolObject {
      flags: 64,
      escapedName: 'IdInterface',
      declarations: [Array],
      members: [Map],
      parent: [SymbolObject],
      id: 40981,
      isReferenced: 788968
    },
    localSymbol: SymbolObject {
      flags: 0,
      escapedName: 'IdInterface',
      declarations: [Array],
      parent: undefined,
      exportSymbol: [SymbolObject]
    },
    nextContainer: NodeObject {
      pos: 253,
      end: 314,
      flags: 0,
      modifierFlagsCache: 536870913,
      transformFlags: 536870913,
      parent: [SourceFileObject],
      kind: 242,
      decorators: undefined,
      modifiers: [Array],
      name: [IdentifierObject],
      typeParameters: undefined,
      heritageClauses: undefined,
      members: [Array],
      symbol: [SymbolObject],
      localSymbol: [SymbolObject],
      nextContainer: [NodeObject]
    }
  },
  identifiers: [
    IdentifierObject {
      pos: 199,
      end: 211,
      flags: 0,
      modifierFlagsCache: 0,
      transformFlags: 536870912,
      parent: [NodeObject],
      escapedText: 'IdInterface',
      flowNode: [Object]
    }
  ],
  synthetic: false,
  _alias: null,
  bestGuessOwningModule: {
    specifier: '@marcj/glut-core',
    resolutionContext: '/Users/marc/bude/deepkit/packages/deepkit/src/app/components/SimpleTableComponent.ts'
  }
} SourceFileObject {
  pos: 0,
  end: 0,
  flags: 0,
  modifierFlagsCache: 0,
  transformFlags: 0,
  parent: undefined,
  kind: 285,
  text: '',
  bindDiagnostics: [],
  bindSuggestionDiagnostics: undefined,
  languageVersion: 99,
  fileName: '/Users/marc/bude/deepkit/packages/deepkit/src/__ng_typecheck__.ts',
  languageVariant: 0,
  isDeclarationFile: false,
  scriptKind: 3,
  pragmas: Map {},
  checkJsDirective: undefined,
  referencedFiles: [],
  typeReferenceDirectives: [],
  libReferenceDirectives: [],
  amdDependencies: [],
  hasNoDefaultLib: false,
  statements: [ pos: 0, end: 0 ],
  endOfFileToken: TokenObject {
    pos: 0,
    end: 0,
    flags: 0,
    modifierFlagsCache: 0,
    transformFlags: 0,
    parent: [Circular],
    kind: 1
  },
  externalModuleIndicator: undefined,
  nodeCount: 2,
 92      * name of the targeted declaration, as it might be different from the declared name (e.g. a
  identifierCount: 0,
  identifiers: Map {},
  parseDiagnostics: []
} 0

As we can see the IdInterface is a interface only. This is used in following component like so:

import {
    Collection,
    IdInterface,
} from '@marcj/glut-core';

export class SimpleTableComponent<T extends IdInterface> implements AfterViewInit, OnChanges, OnDestroy {
    @Input() public items!: T[] | Collection<T>;

   //snap
}

🌍 Your Environment

Angular CLI: 9.0.0-rc.8
Node: 12.14.1
OS: darwin x64

Angular: 9.0.0-rc.9
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.900.0-rc.8
@angular-devkit/build-angular     0.900.0-rc.8
@angular-devkit/build-optimizer   0.900.0-rc.8
@angular-devkit/build-webpack     0.900.0-rc.8
@angular-devkit/core              9.0.0-rc.8
@angular-devkit/schematics        9.0.0-rc.8
@angular/cdk                      9.0.0-rc.7
@angular/cli                      9.0.0-rc.8
@angular/http                     7.2.15
@ngtools/webpack                  9.0.0-rc.8
@schematics/angular               9.0.0-rc.8
@schematics/update                0.900.0-rc.8
rxjs                              6.5.3
typescript                        3.6.4
webpack                           4.41.2

Anything else relevant?

@JoostK
Copy link
Member

JoostK commented Jan 17, 2020

No need for a repro, I see what's going on here! It's indeed a bug introduced in #34021.

@JoostK JoostK added area: compiler Issues related to `ngc`, Angular's template compiler comp: ivy freq1: low type: bug/fix labels Jan 17, 2020
@ngbot ngbot bot added this to the Backlog milestone Jan 17, 2020
@JoostK JoostK self-assigned this Jan 17, 2020
JoostK added a commit to JoostK/angular that referenced this issue Jan 18, 2020
In angular#34021 the ngtsc compiler gained the ability to emit type parameter
constraints, which would generate imports for any type reference that
is used within the constraint. However, the `AbsoluteModuleStrategy`
reference emitter strategy did not consider interface declarations as a
valid declaration it can generate an import for, throwing an error
instead.

This commit fixes the issue by including interface declarations in the
logic that determines whether something is a declaration.

Fixes angular#34837
@JoostK
Copy link
Member

JoostK commented Jan 18, 2020

To workaround the issue you could change the SimpleTableComponent as follows:

export type IdInterface_Ng34837 = IdInterface;
export class SimpleTableComponent<T extends IdInterface_Ng34837 >

Introducing the local type alias prevents the type emitter from kicking in, avoiding the issue.

@marcj
Copy link
Author

marcj commented Jan 19, 2020

@JoostK wonderful, thanks!

JoostK added a commit to JoostK/angular that referenced this issue Feb 3, 2020
In angular#34021 the ngtsc compiler gained the ability to emit type parameter
constraints, which would generate imports for any type reference that
is used within the constraint. However, the `AbsoluteModuleStrategy`
reference emitter strategy did not consider interface declarations as a
valid declaration it can generate an import for, throwing an error
instead.

This commit fixes the issue by including interface declarations in the
logic that determines whether something is a declaration.

Fixes angular#34837
mhevery pushed a commit that referenced this issue Feb 4, 2020
)

In #34021 the ngtsc compiler gained the ability to emit type parameter
constraints, which would generate imports for any type reference that
is used within the constraint. However, the `AbsoluteModuleStrategy`
reference emitter strategy did not consider interface declarations as a
valid declaration it can generate an import for, throwing an error
instead.

This commit fixes the issue by including interface declarations in the
logic that determines whether something is a declaration.

Fixes #34837

PR Close #34849
@mhevery mhevery closed this as completed in 6ddf550 Feb 4, 2020
@surenrao
Copy link

surenrao commented Feb 5, 2020

To workaround the issue you could change the SimpleTableComponent as follows:

export type IdInterface_Ng34837 = IdInterface;
export class SimpleTableComponent<T extends IdInterface_Ng34837 >

Introducing the local type alias prevents the type emitter from kicking in, avoiding the issue.

This error happened for me for 9.0.0-rc.14
and adding local type alias fixed the issue

@JoostK
Copy link
Member

JoostK commented Feb 5, 2020

@surenrao The fix will be part of the next release, it just missed rc.14

sonukapoor pushed a commit to sonukapoor/angular that referenced this issue Feb 13, 2020
…ular#34849)

In angular#34021 the ngtsc compiler gained the ability to emit type parameter
constraints, which would generate imports for any type reference that
is used within the constraint. However, the `AbsoluteModuleStrategy`
reference emitter strategy did not consider interface declarations as a
valid declaration it can generate an import for, throwing an error
instead.

This commit fixes the issue by including interface declarations in the
logic that determines whether something is a declaration.

Fixes angular#34837

PR Close angular#34849
sonukapoor pushed a commit to sonukapoor/angular that referenced this issue Feb 17, 2020
…ular#34849)

In angular#34021 the ngtsc compiler gained the ability to emit type parameter
constraints, which would generate imports for any type reference that
is used within the constraint. However, the `AbsoluteModuleStrategy`
reference emitter strategy did not consider interface declarations as a
valid declaration it can generate an import for, throwing an error
instead.

This commit fixes the issue by including interface declarations in the
logic that determines whether something is a declaration.

Fixes angular#34837

PR Close angular#34849
@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 Mar 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: compiler Issues related to `ngc`, Angular's template compiler freq1: low state: has PR type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants