Skip to content

Commit 4822206

Browse files
committed
refactor(language-service): initial use of type-only imports and standard server types
This commit converts the typescript import in api.ts to a type-only import and updates the plugin factory to utilize standard TypeScript server types. Internal interfaces and specific service types are replaced with general types to decouple the factory wrapper from internal implementations.
1 parent d072791 commit 4822206

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

packages/language-service/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Entry point for all public APIs of the language service package.
1313
*/
1414

15-
import ts from 'typescript';
15+
import type ts from 'typescript';
1616

1717
export interface PluginConfig {
1818
/**

packages/language-service/plugin-factory.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,19 @@
99
// Note: use a type-only import to prevent TypeScript from being bundled in.
1010
import type ts from 'typescript';
1111

12-
import {NgLanguageService, PluginConfig} from './api';
13-
14-
interface PluginModule extends ts.server.PluginModule {
15-
create(createInfo: ts.server.PluginCreateInfo): NgLanguageService;
16-
onConfigurationChanged?(config: PluginConfig): void;
17-
}
18-
19-
export const factory: ts.server.PluginModuleFactory = (tsModule): PluginModule => {
20-
let plugin: PluginModule;
12+
export const factory: ts.server.PluginModuleFactory = (tsModule) => {
13+
let plugin: ts.server.PluginModule;
2114

2215
return {
23-
create(info: ts.server.PluginCreateInfo): NgLanguageService {
16+
create(info: ts.server.PluginCreateInfo): ts.LanguageService {
2417
plugin ??= require(`@angular/language-service/bundles/language-service.js`)(tsModule);
18+
2519
return plugin.create(info);
2620
},
2721
getExternalFiles(project: ts.server.Project): string[] {
2822
return plugin?.getExternalFiles?.(project, tsModule.typescript.ProgramUpdateLevel.Full) ?? [];
2923
},
30-
onConfigurationChanged(config: PluginConfig): void {
24+
onConfigurationChanged(config: unknown): void {
3125
plugin?.onConfigurationChanged?.(config);
3226
},
3327
};

0 commit comments

Comments
 (0)