Skip to content

Commit daf7772

Browse files
committed
Removed Typescript as a constructor argument to instead use the one that is located in node_modules.
1 parent e029d2f commit daf7772

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ The LanguageService will not track any mutations for already-initialized variabl
100100

101101
## Changelog:
102102

103+
**v1.0.16**:
104+
105+
- Removed Typescript as a constructor argument to instead use the one that is located in node_modules.
106+
103107
**v1.0.15**:
104108

105109
- Added a blacklist filter for specific file names (such as tslib.ts or rollup plugins.)

src/service/CodeAnalyzer.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {IFileLoader} from "@wessberg/fileloader";
22
import {IMarshaller} from "@wessberg/marshaller";
3-
import * as ts from "typescript";
3+
import * as typescript from "typescript";
44
import {ArrowFunction, BinaryExpression, CallExpression, ClassDeclaration, CompilerOptions, Declaration, ExportAssignment, ExportDeclaration, Expression, ExpressionStatement, FunctionDeclaration, ImportDeclaration, ImportEqualsDeclaration, IScriptSnapshot, LanguageService, ModuleKind, Node, NodeArray, ScriptTarget, Statement, SyntaxKind, VariableStatement} from "typescript";
55
import {Cache} from "../cache/Cache";
66
import {ICache} from "../cache/interface/ICache";
@@ -125,9 +125,8 @@ export class CodeAnalyzer implements ICodeAnalyzer {
125125
private typeUtil: ITypeUtil;
126126
private files: Map<string, { version: number, content: string }> = new Map();
127127
constructor (private marshaller: IMarshaller,
128-
private fileLoader: IFileLoader,
129-
public typescript: typeof ts = ts) {
130-
this.languageService = this.typescript.createLanguageService(this, typescript.createDocumentRegistry());
128+
private fileLoader: IFileLoader) {
129+
this.languageService = typescript.createLanguageService(this, typescript.createDocumentRegistry());
131130
this.typeUtil = new TypeUtil();
132131
this.tokenSerializer = new TokenSerializer();
133132
this.tokenPredicator = new TokenPredicator();
@@ -260,7 +259,7 @@ export class CodeAnalyzer implements ICodeAnalyzer {
260259
public getScriptSnapshot (fileName: string): IScriptSnapshot|undefined {
261260
const file = this.files.get(fileName);
262261
if (file == null) return undefined;
263-
return this.typescript.ScriptSnapshot.fromString(file.content);
262+
return typescript.ScriptSnapshot.fromString(file.content);
264263
}
265264

266265
/**
@@ -277,7 +276,7 @@ export class CodeAnalyzer implements ICodeAnalyzer {
277276
* @returns {string}
278277
*/
279278
public getDefaultLibFileName (options: CompilerOptions): string {
280-
return this.typescript.getDefaultLibFilePath(options);
279+
return typescript.getDefaultLibFilePath(options);
281280
}
282281

283282
/**

src/service/interface/ICodeAnalyzer.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as ts from "typescript";
21
import {ArrayLiteralExpression, BooleanLiteral, Expression, LanguageServiceHost, Node, NodeArray, NoSubstitutionTemplateLiteral, NumericLiteral, ObjectLiteralExpression, RegularExpressionLiteral, Statement, StringLiteral, SyntaxKind} from "typescript";
32

43
import {IBindingIdentifier} from "../../model/interface/IBindingIdentifier";
@@ -313,7 +312,6 @@ export declare type ArbitraryValueArray = ArbitraryValueIndexable[];
313312
export declare type InitializationValue = ArbitraryValueArray;
314313

315314
export interface ICodeAnalyzer extends LanguageServiceHost {
316-
typescript: typeof ts;
317315
addFile (fileName: string, content: string, version?: number): NodeArray<Statement>;
318316
getFile(fileName: string): NodeArray<Statement>;
319317
removeFile (fileName: string): void;

0 commit comments

Comments
 (0)