From 68025ce09a81c3beff2265ff45ee7685acbf37c3 Mon Sep 17 00:00:00 2001 From: ayazhafiz Date: Mon, 20 Jan 2020 11:31:15 -0800 Subject: [PATCH] test(language-service): recognize inputs/ouputs declared in decorator (#34875) This commit adds a regression test to check that the language service recognizes inputs and outputs declared in a directive decorator. See #34874. PR Close #34875 --- packages/language-service/test/diagnostics_spec.ts | 8 ++++++++ packages/language-service/test/project/app/main.ts | 1 + .../language-service/test/project/app/parsing-cases.ts | 10 ++++++++++ 3 files changed, 19 insertions(+) diff --git a/packages/language-service/test/diagnostics_spec.ts b/packages/language-service/test/diagnostics_spec.ts index ea24084416..4acdd08551 100644 --- a/packages/language-service/test/diagnostics_spec.ts +++ b/packages/language-service/test/diagnostics_spec.ts @@ -646,6 +646,14 @@ describe('diagnostics', () => { expect(ngDiags).toEqual([]); }); + // Issue https://github.com/angular/angular/issues/34874 + it('should recognize inputs and outputs listed inside directive decorators', () => { + mockHost.override( + TEST_TEMPLATE, `
`); + const ngDiags = ngLS.getSemanticDiagnostics(TEST_TEMPLATE); + expect(ngDiags).toEqual([]); + }); + it('should be able to resolve modules using baseUrl', () => { mockHost.override(APP_COMPONENT, ` import { Component } from '@angular/core'; diff --git a/packages/language-service/test/project/app/main.ts b/packages/language-service/test/project/app/main.ts index defe0c4372..31dab5c379 100644 --- a/packages/language-service/test/project/app/main.ts +++ b/packages/language-service/test/project/app/main.ts @@ -34,6 +34,7 @@ import * as ParsingCases from './parsing-cases'; ParsingCases.CaseMissingClosing, ParsingCases.CaseUnknown, ParsingCases.EmptyInterpolation, + ParsingCases.HintModel, ParsingCases.NoValueAttribute, ParsingCases.NumberModel, ParsingCases.Pipes, diff --git a/packages/language-service/test/project/app/parsing-cases.ts b/packages/language-service/test/project/app/parsing-cases.ts index 4ed8c4c787..77e6753add 100644 --- a/packages/language-service/test/project/app/parsing-cases.ts +++ b/packages/language-service/test/project/app/parsing-cases.ts @@ -60,6 +60,16 @@ export class NumberModel { @Output('outputAlias') modelChange: EventEmitter = new EventEmitter(); } +@Directive({ + selector: '[hint-model]', + inputs: ['hint'], + outputs: ['hintChange'], +}) +export class HintModel { + hint: string = 'hint'; + hintChange: EventEmitter = new EventEmitter(); +} + interface Person { name: string; age: number;