Skip to content

Compilation error using conditional types + property decorators #27999

Closed
@marshall007

Description

@marshall007

TypeScript Version: 3.1.3 and 3.2.0-dev.20181019

Search Terms: Debug Failure. Unexpected node. Node 173 was unexpected.

Code

function Column(): PropertyDecorator {
  return () => undefined;
}

export abstract class BaseEntity<T> {
  @Column()
  public attributes: T extends { attributes: infer A } ? A : undefined;
}

Expected behavior:

The program should successfully compile. Note that the specific implementation of the decorator function does not matter.

Actual behavior:

Error: Debug Failure. Unexpected node.
Node 173 was unexpected.
    at serializeTypeNode (/opt/app/node_modules/typescript/lib/tsc.js:54893:37)
    at serializeTypeOfNode (/opt/app/node_modules/typescript/lib/tsc.js:54779:28)
    at addOldTypeMetadata (/opt/app/node_modules/typescript/lib/tsc.js:54721:92)
    at addTypeMetadata (/opt/app/node_modules/typescript/lib/tsc.js:54715:17)
    at transformAllDecoratorsOfDeclaration (/opt/app/node_modules/typescript/lib/tsc.js:54634:13)
    at generateClassElementDecorationExpression (/opt/app/node_modules/typescript/lib/tsc.js:54659:40)
    at generateClassElementDecorationExpressions (/opt/app/node_modules/typescript/lib/tsc.js:54645:34)
    at addClassElementDecorationStatements (/opt/app/node_modules/typescript/lib/tsc.js:54638:44)
    at visitClassDeclaration (/opt/app/node_modules/typescript/lib/tsc.js:54314:13)
    at visitTypeScript (/opt/app/node_modules/typescript/lib/tsc.js:54206:28)

Metadata

Metadata

Assignees

Labels

CrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad outputDomain: DecoratorsThe issue relates to the decorator syntaxFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions