fix(language-service): Add global symbol for $any() (#33245)
This commit introduces a "global symbol table" in the language service for symbols that are available in the top level scope, and add `$any()` to it. See https://angular.io/guide/template-syntax#the-any-type-cast-function PR closes https://github.com/angular/vscode-ng-language-service/issues/242 PR Close #33245
This commit is contained in:

committed by
Andrew Kushnir

parent
8bc5fb2ab6
commit
3f257e96c6
28
packages/language-service/test/global_symbols_spec.ts
Normal file
28
packages/language-service/test/global_symbols_spec.ts
Normal file
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {getSymbolQuery} from '@angular/compiler-cli';
|
||||
import * as ts from 'typescript/lib/tsserverlibrary';
|
||||
|
||||
import {EMPTY_SYMBOL_TABLE, createGlobalSymbolTable} from '../src/global_symbols';
|
||||
|
||||
import {MockTypescriptHost} from './test_utils';
|
||||
|
||||
describe('GlobalSymbolTable', () => {
|
||||
const mockHost = new MockTypescriptHost([]);
|
||||
const tsLS = ts.createLanguageService(mockHost);
|
||||
|
||||
it(`contains $any()`, () => {
|
||||
const program = tsLS.getProgram() !;
|
||||
const typeChecker = program.getTypeChecker();
|
||||
const source = ts.createSourceFile('foo.ts', '', ts.ScriptTarget.ES2015);
|
||||
const query = getSymbolQuery(program, typeChecker, source, () => EMPTY_SYMBOL_TABLE);
|
||||
const table = createGlobalSymbolTable(query);
|
||||
expect(table.has('$any')).toBe(true);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user