Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates typescript to 2.7.1 version #686

Merged
merged 5 commits into from
Feb 10, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
"husky": "^0.14.3",
"lint-staged": "^6.0.0",
"tslint": "^5.8.0",
"typescript": "^2.6.2",
"typescript": "^2.7.1",
"vscode": "^1.1.5"
}
}
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"prettier-eslint": "^8.3.1",
"stylus": "^0.54.5",
"stylus-supremacy": "~2.7.3",
"typescript": "^2.6.2",
"typescript": "^2.7.1",
"vscode-css-languageservice": "^3.0.3",
"vscode-emmet-helper": "^1.1.19",
"vscode-languageserver": "^3.5.0",
Expand Down
2 changes: 1 addition & 1 deletion server/src/modes/script/findComponents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface ComponentInfo {
export function findComponents(service: ts.LanguageService, fileFsPath: string): ComponentInfo[] {
const program = service.getProgram();
const sourceFile = program.getSourceFile(fileFsPath);
const exportStmt = sourceFile.statements.filter(st => st.kind === ts.SyntaxKind.ExportAssignment);
const exportStmt = sourceFile!.statements.filter(st => st.kind === ts.SyntaxKind.ExportAssignment);
if (exportStmt.length === 0) {
return [];
}
Expand Down
5 changes: 3 additions & 2 deletions server/src/modes/script/javascript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ export function getJavascriptMode(
fileFsPath,
offset,
{
includeExternalModuleExports: _.get(config, ['vetur', 'completion', 'autoImport'])
includeExternalModuleExports: _.get(config, ['vetur', 'completion', 'autoImport']),
includeInsertTextCompletions: false
}
);
if (!completions) {
Expand Down Expand Up @@ -294,7 +295,7 @@ export function getJavascriptMode(
const program = service.getProgram();
definitions.forEach(d => {
const sourceFile = program.getSourceFile(d.fileName);
Copy link
Member

@HerringtonDarkholme HerringtonDarkholme Feb 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

definitive assertion should add here. Getting sourceFile from declaration is expected to be non null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I doesn't get that. getSourceFile returns ts.SourceFile | undefined in 2.7.1. To get rid of errors I had add to add exclamation mark on 298. It is not allowed to add it on line:col (296:25). Another solution is to add if with return statement.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const definitionTargetDoc = TextDocument.create(d.fileName, 'vue', 0, sourceFile.getText());
const definitionTargetDoc = TextDocument.create(d.fileName, 'vue', 0, sourceFile!.getText());
definitionResults.push({
uri: Uri.file(d.fileName).toString(),
range: convertRange(definitionTargetDoc, d.textSpan)
Expand Down
8 changes: 4 additions & 4 deletions server/src/modes/template/parser/htmlParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { isEmptyElement } from '../tagProviders/htmlTags';
import { TextDocument } from 'vscode-languageserver-types';

export class Node {
public tag: string;
public closed: boolean;
public endTagStart: number;
public attributes: { [name: string]: string };
public tag!: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since 2.7.1 it isn't allowed to declare properties without initialization when strict flag is set inside tsconfig. Typescript throws there error even though you null check that later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can declare it as optional or typing it as string | undefined

public closed!: boolean;
public endTagStart!: number;
public attributes!: { [name: string]: string };
public get attributeNames(): string[] {
return Object.keys(this.attributes);
}
Expand Down
2 changes: 1 addition & 1 deletion server/src/modes/template/tagProviders/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function getTagProviderSettings(workspacePath: string | null | undefined)
return settings;
}
try {
const packagePath = ts.findConfigFile(workspacePath, ts.sys.fileExists, 'package.json');
const packagePath = ts.findConfigFile(workspacePath, ts.sys.fileExists, 'package.json') || '';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If package is not found, it should return early. Empty path doesn't make much sense.

const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf-8'));
if (packageJson.dependencies['vue-router']) {
settings['router'] = true;
Expand Down
2 changes: 1 addition & 1 deletion server/src/modes/test-util/completion-test-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function testDSL(setup: CompletionTestSetup): (text: TemplateStringsArray
}

export class CompletionAsserter {
lastMatch: CompletionItem;
lastMatch!: CompletionItem;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like lastMatch is better modeled as CompletionItem | undefined. https://github.com/vuejs/vetur/pull/686/files#diff-8c1c99640c5e32e1403b16bc16ec3849R61

But I'm fine with current writing since lastMatch is always called after has.

constructor(public items: CompletionItem[], public doc: TextDocument) {}
count(expect: number) {
const actual = this.items.length;
Expand Down
6 changes: 5 additions & 1 deletion server/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2165,10 +2165,14 @@ typescript-eslint-parser@^8.0.0:
lodash.unescape "4.0.1"
semver "5.4.1"

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

typescript@^2.7.1:
version "2.7.1"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.7.1.tgz#bb3682c2c791ac90e7c6210b26478a8da085c359"

uid-number@^0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81"
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2084,9 +2084,9 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0:
version "0.14.5"
resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64"

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

unique-stream@^2.0.2:
version "2.2.1"
Expand Down