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 all 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 @@ -15,7 +15,7 @@ export interface ComponentInfo {

export function findComponents(service: ts.LanguageService, fileFsPath: string): ComponentInfo[] {
const program = service.getProgram();
const sourceFile = program.getSourceFile(fileFsPath);
const sourceFile = program.getSourceFile(fileFsPath)!;
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 @@ -293,7 +294,7 @@ export function getJavascriptMode(
const definitionResults: Definition = [];
const program = service.getProgram();
definitions.forEach(d => {
const sourceFile = program.getSourceFile(d.fileName);
const sourceFile = program.getSourceFile(d.fileName)!;
const definitionTargetDoc = TextDocument.create(d.fileName, 'vue', 0, sourceFile.getText());
definitionResults.push({
uri: Uri.file(d.fileName).toString(),
Expand Down
16 changes: 10 additions & 6 deletions server/src/modes/template/parser/htmlParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ 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;
public closed?: boolean;
public endTagStart?: number;
public attributes?: { [name: string]: string };
public get attributeNames(): string[] {
return Object.keys(this.attributes);
if(this.attributes) {
return Object.keys(this.attributes);
}

return [];
}
constructor(public start: number, public end: number, public children: Node[], public parent: Node) {}
public isSameTag(tagInLowerCase: string) {
Expand Down Expand Up @@ -70,7 +74,7 @@ export function parse(text: string): HTMLDocument {
let endTagStart = -1;
let pendingAttribute = '';
let token = scanner.scan();
let attributes: { [k: string]: string } = {};
let attributes: { [k: string]: string } | undefined = {};
while (token !== TokenType.EOS) {
switch (token) {
case TokenType.StartTagOpen:
Expand Down
2 changes: 1 addition & 1 deletion server/src/modes/template/services/htmlCompletion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export function doComplete(
let curr = node;
while (curr) {
const tag = curr.tag;
if (tag && (!curr.closed || curr.endTagStart > offset)) {
if (tag && (!curr.closed || curr.endTagStart && (curr.endTagStart > offset))) {
const item: CompletionItem = {
label: '/' + tag,
kind: CompletionItemKind.Property,
Expand Down
4 changes: 4 additions & 0 deletions server/src/modes/template/services/htmlSymbolsProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ function provideFileSymbolsInternal(
function nodeToName(node: Node): string {
let name = node.tag;

if(!name) {
return '';
}

if (node.attributes) {
const id = node.attributes['id'];
const classes = node.attributes['class'];
Expand Down
2 changes: 1 addition & 1 deletion server/src/modes/template/tagProviders/htmlTags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const EMPTY_ELEMENTS: string[] = [
'wbr'
];

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

Expand Down
3 changes: 3 additions & 0 deletions server/src/modes/template/tagProviders/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export function getTagProviderSettings(workspacePath: string | null | undefined)
}
try {
const packagePath = ts.findConfigFile(workspacePath, ts.sys.fileExists, 'package.json');
if(!packagePath) {
return settings;
}
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