Skip to content

Commit 6a8e76b

Browse files
GoszczularHerringtonDarkholme
Goszczular
authored andcommitted
Updates typescript to 2.7.1 version (#686)
* updates typescript to 2.7.1 * fixes typescript errors after upgrade to 2.7.1 * fixes nulls * moves definite assignment assertion modifier to method invocation * changes bangs to optional properties
1 parent 52f2b15 commit 6a8e76b

12 files changed

+34
-18
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@
291291
"husky": "^0.14.3",
292292
"lint-staged": "^6.0.0",
293293
"tslint": "^5.8.0",
294-
"typescript": "^2.6.2",
294+
"typescript": "^2.7.1",
295295
"vscode": "^1.1.5"
296296
}
297297
}

server/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"prettier-eslint": "^8.3.1",
3333
"stylus": "^0.54.5",
3434
"stylus-supremacy": "~2.7.3",
35-
"typescript": "^2.6.2",
35+
"typescript": "^2.7.1",
3636
"vscode-css-languageservice": "^3.0.3",
3737
"vscode-emmet-helper": "^1.1.19",
3838
"vscode-languageserver": "^3.5.0",

server/src/modes/script/findComponents.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface ComponentInfo {
1515

1616
export function findComponents(service: ts.LanguageService, fileFsPath: string): ComponentInfo[] {
1717
const program = service.getProgram();
18-
const sourceFile = program.getSourceFile(fileFsPath);
18+
const sourceFile = program.getSourceFile(fileFsPath)!;
1919
const exportStmt = sourceFile.statements.filter(st => st.kind === ts.SyntaxKind.ExportAssignment);
2020
if (exportStmt.length === 0) {
2121
return [];

server/src/modes/script/javascript.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ export function getJavascriptMode(
101101
fileFsPath,
102102
offset,
103103
{
104-
includeExternalModuleExports: _.get(config, ['vetur', 'completion', 'autoImport'])
104+
includeExternalModuleExports: _.get(config, ['vetur', 'completion', 'autoImport']),
105+
includeInsertTextCompletions: false
105106
}
106107
);
107108
if (!completions) {
@@ -293,7 +294,7 @@ export function getJavascriptMode(
293294
const definitionResults: Definition = [];
294295
const program = service.getProgram();
295296
definitions.forEach(d => {
296-
const sourceFile = program.getSourceFile(d.fileName);
297+
const sourceFile = program.getSourceFile(d.fileName)!;
297298
const definitionTargetDoc = TextDocument.create(d.fileName, 'vue', 0, sourceFile.getText());
298299
definitionResults.push({
299300
uri: Uri.file(d.fileName).toString(),

server/src/modes/template/parser/htmlParser.ts

+10-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ import { isEmptyElement } from '../tagProviders/htmlTags';
33
import { TextDocument } from 'vscode-languageserver-types';
44

55
export class Node {
6-
public tag: string;
7-
public closed: boolean;
8-
public endTagStart: number;
9-
public attributes: { [name: string]: string };
6+
public tag?: string;
7+
public closed?: boolean;
8+
public endTagStart?: number;
9+
public attributes?: { [name: string]: string };
1010
public get attributeNames(): string[] {
11-
return Object.keys(this.attributes);
11+
if(this.attributes) {
12+
return Object.keys(this.attributes);
13+
}
14+
15+
return [];
1216
}
1317
constructor(public start: number, public end: number, public children: Node[], public parent: Node) {}
1418
public isSameTag(tagInLowerCase: string) {
@@ -70,7 +74,7 @@ export function parse(text: string): HTMLDocument {
7074
let endTagStart = -1;
7175
let pendingAttribute = '';
7276
let token = scanner.scan();
73-
let attributes: { [k: string]: string } = {};
77+
let attributes: { [k: string]: string } | undefined = {};
7478
while (token !== TokenType.EOS) {
7579
switch (token) {
7680
case TokenType.StartTagOpen:

server/src/modes/template/services/htmlCompletion.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export function doComplete(
8484
let curr = node;
8585
while (curr) {
8686
const tag = curr.tag;
87-
if (tag && (!curr.closed || curr.endTagStart > offset)) {
87+
if (tag && (!curr.closed || curr.endTagStart && (curr.endTagStart > offset))) {
8888
const item: CompletionItem = {
8989
label: '/' + tag,
9090
kind: CompletionItemKind.Property,

server/src/modes/template/services/htmlSymbolsProvider.ts

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ function provideFileSymbolsInternal(
3939
function nodeToName(node: Node): string {
4040
let name = node.tag;
4141

42+
if(!name) {
43+
return '';
44+
}
45+
4246
if (node.attributes) {
4347
const id = node.attributes['id'];
4448
const classes = node.attributes['class'];

server/src/modes/template/tagProviders/htmlTags.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const EMPTY_ELEMENTS: string[] = [
5151
'wbr'
5252
];
5353

54-
export function isEmptyElement(e: string): boolean {
54+
export function isEmptyElement(e: string | undefined): boolean {
5555
return !!e && binarySearch(EMPTY_ELEMENTS, e.toLowerCase(), (s1: string, s2: string) => s1.localeCompare(s2)) >= 0;
5656
}
5757

server/src/modes/template/tagProviders/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ export function getTagProviderSettings(workspacePath: string | null | undefined)
3838
}
3939
try {
4040
const packagePath = ts.findConfigFile(workspacePath, ts.sys.fileExists, 'package.json');
41+
if(!packagePath) {
42+
return settings;
43+
}
4144
const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf-8'));
4245
if (packageJson.dependencies['vue-router']) {
4346
settings['router'] = true;

server/src/modes/test-util/completion-test-util.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function testDSL(setup: CompletionTestSetup): (text: TemplateStringsArray
2727
}
2828

2929
export class CompletionAsserter {
30-
lastMatch: CompletionItem;
30+
lastMatch!: CompletionItem;
3131
constructor(public items: CompletionItem[], public doc: TextDocument) {}
3232
count(expect: number) {
3333
const actual = this.items.length;

server/yarn.lock

+5-1
Original file line numberDiff line numberDiff line change
@@ -2165,10 +2165,14 @@ typescript-eslint-parser@^8.0.0:
21652165
lodash.unescape "4.0.1"
21662166
semver "5.4.1"
21672167

2168-
typescript@^2.5.1, typescript@^2.6.2:
2168+
typescript@^2.5.1:
21692169
version "2.6.2"
21702170
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.6.2.tgz#3c5b6fd7f6de0914269027f03c0946758f7673a4"
21712171

2172+
typescript@^2.7.1:
2173+
version "2.7.1"
2174+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.7.1.tgz#bb3682c2c791ac90e7c6210b26478a8da085c359"
2175+
21722176
uid-number@^0.0.6:
21732177
version "0.0.6"
21742178
resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81"

yarn.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -2084,9 +2084,9 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0:
20842084
version "0.14.5"
20852085
resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64"
20862086

2087-
typescript@^2.6.2:
2088-
version "2.6.2"
2089-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.6.2.tgz#3c5b6fd7f6de0914269027f03c0946758f7673a4"
2087+
typescript@^2.7.1:
2088+
version "2.7.1"
2089+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.7.1.tgz#bb3682c2c791ac90e7c6210b26478a8da085c359"
20902090

20912091
unique-stream@^2.0.2:
20922092
version "2.2.1"

0 commit comments

Comments
 (0)