diff --git a/packages/compiler-cli/src/ngtsc/typecheck/src/completion.ts b/packages/compiler-cli/src/ngtsc/typecheck/src/completion.ts
index 645a628967f..48e64cb3045 100644
--- a/packages/compiler-cli/src/ngtsc/typecheck/src/completion.ts
+++ b/packages/compiler-cli/src/ngtsc/typecheck/src/completion.ts
@@ -7,7 +7,7 @@
*/
import {TmplAstReference, TmplAstTemplate} from '@angular/compiler';
-import {AST, EmptyExpr, LiteralPrimitive, MethodCall, PropertyRead, PropertyWrite, SafeMethodCall, SafePropertyRead, TmplAstNode} from '@angular/compiler/src/compiler';
+import {AST, EmptyExpr, ImplicitReceiver, LiteralPrimitive, MethodCall, PropertyRead, PropertyWrite, SafeMethodCall, SafePropertyRead, TmplAstNode} from '@angular/compiler/src/compiler';
import {TextAttribute} from '@angular/compiler/src/render3/r3_ast';
import * as ts from 'typescript';
@@ -91,6 +91,19 @@ export class CompletionEngine {
}
}
+ if (node instanceof PropertyRead && node.receiver instanceof ImplicitReceiver) {
+ const nodeLocation = findFirstMatchingNode(this.tcb, {
+ filter: ts.isPropertyAccessExpression,
+ withSpan: node.sourceSpan,
+ });
+ if (nodeLocation) {
+ nodeContext = {
+ shimPath: this.shimPath,
+ positionInShimFile: nodeLocation.getStart(),
+ };
+ }
+ }
+
return {
componentContext: this.componentContext,
templateContext,
diff --git a/packages/language-service/ivy/test/completions_spec.ts b/packages/language-service/ivy/test/completions_spec.ts
index 6a2a05b806a..83c565119fe 100644
--- a/packages/language-service/ivy/test/completions_spec.ts
+++ b/packages/language-service/ivy/test/completions_spec.ts
@@ -234,6 +234,18 @@ describe('completions', () => {
const {templateFile} = setup(``, '', DIR_WITH_UNION_TYPE_INPUT);
templateFile.moveCursorToText('dir [myInput]="¦">');
+ const completions = templateFile.getCompletionsAtPosition();
+ expectContain(completions, ts.ScriptElementKind.string, [`'foo'`, '42']);
+ expectContain(completions, ts.ScriptElementKind.keyword, ['null']);
+ expectContain(completions, ts.ScriptElementKind.variableElement, ['undefined']);
+ expectDoesNotContain(completions, ts.ScriptElementKind.parameterElement, ['ctx']);
+ });
+
+ it('should return completions of string literals, number literals, `true`, `false`, `null` and `undefined` when the user tries to modify the symbol',
+ () => {
+ const {templateFile} = setup(``, '', DIR_WITH_UNION_TYPE_INPUT);
+ templateFile.moveCursorToText('dir [myInput]="a¦">');
+
const completions = templateFile.getCompletionsAtPosition();
expectContain(completions, ts.ScriptElementKind.string, [`'foo'`, '42']);
expectContain(completions, ts.ScriptElementKind.keyword, ['null']);