diff --git a/dist/main/lang/fixmyts/quickFixes/typeAssertPropertyAccessToAny.js b/dist/main/lang/fixmyts/quickFixes/typeAssertPropertyAccessToAny.js index be8213084..ee6aec2bc 100644 --- a/dist/main/lang/fixmyts/quickFixes/typeAssertPropertyAccessToAny.js +++ b/dist/main/lang/fixmyts/quickFixes/typeAssertPropertyAccessToAny.js @@ -19,8 +19,10 @@ var TypeAssertPropertyAccessToAny = (function () { var parent = info.positionNode.parent; if (parent.kind == ts.SyntaxKind.PropertyAccessExpression) { var propertyAccess = parent; + var idx = propertyAccess.getChildren().indexOf(info.positionNode); + var prev = propertyAccess.getChildAt(idx - 2); var start = propertyAccess.getStart(); - var end = propertyAccess.dotToken.getStart(); + var end = prev.getEnd(); var oldText = propertyAccess.getText().substr(0, end - start); var refactoring = { filePath: info.filePath, diff --git a/dist/main/lang/fixmyts/quickFixes/typeAssertPropertyAccessToType.js b/dist/main/lang/fixmyts/quickFixes/typeAssertPropertyAccessToType.js index 7ddbea954..b831086c8 100644 --- a/dist/main/lang/fixmyts/quickFixes/typeAssertPropertyAccessToType.js +++ b/dist/main/lang/fixmyts/quickFixes/typeAssertPropertyAccessToType.js @@ -19,8 +19,10 @@ var TypeAssertPropertyAccessToType = (function () { var parent = info.positionNode.parent; if (parent.kind == ts.SyntaxKind.PropertyAccessExpression) { var propertyAccess = parent; + var idx = propertyAccess.getChildren().indexOf(info.positionNode); + var prev = propertyAccess.getChildAt(idx - 2); var start = propertyAccess.getStart(); - var end = propertyAccess.dotToken.getStart(); + var end = prev.getEnd(); var oldText = propertyAccess.getText().substr(0, end - start); var refactoring = { filePath: info.filePath, diff --git a/dist/main/tsconfig/simpleValidator.js b/dist/main/tsconfig/simpleValidator.js index a75fd158e..69b80d922 100644 --- a/dist/main/tsconfig/simpleValidator.js +++ b/dist/main/tsconfig/simpleValidator.js @@ -2,7 +2,8 @@ exports.types = { string: 'string', boolean: 'boolean', - number: 'number' + number: 'number', + object: 'object' }; var SimpleValidator = (function () { function SimpleValidator(validationInfo) { diff --git a/dist/main/tsconfig/tsconfig.js b/dist/main/tsconfig/tsconfig.js index 761f2ee3b..f916f6e59 100644 --- a/dist/main/tsconfig/tsconfig.js +++ b/dist/main/tsconfig/tsconfig.js @@ -27,6 +27,9 @@ var compilerOptionsValidation = { mapRoot: { type: types.string }, module: { type: types.string, validValues: ['commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'] }, moduleResolution: { type: types.string, validValues: ['classic', 'node'] }, + baseUrl: { type: types.string }, + paths: { type: types.object }, + rootDirs: { type: types.object }, newLine: { type: types.string }, noEmit: { type: types.boolean }, noEmitHelpers: { type: types.boolean }, @@ -167,6 +170,14 @@ function rawToTsCompilerOptions(jsonOptions, projectDir) { if (compilerOptions.outFile !== undefined) { compilerOptions.outFile = path.resolve(projectDir, compilerOptions.outFile); } + if (compilerOptions.baseUrl !== undefined) { + compilerOptions.baseUrl = path.resolve(projectDir, compilerOptions.baseUrl); + } + if (compilerOptions.rootDirs !== undefined && Array.isArray(compilerOptions.rootDirs)) { + compilerOptions.rootDirs = compilerOptions.rootDirs.map(function (dir) { + return path.resolve(projectDir, dir); + }); + } return compilerOptions; } function tsToRawCompilerOptions(compilerOptions) { diff --git a/lib/main/lang/fixmyts/quickFixes/typeAssertPropertyAccessToAny.ts b/lib/main/lang/fixmyts/quickFixes/typeAssertPropertyAccessToAny.ts index f71bea8c9..185f9d126 100644 --- a/lib/main/lang/fixmyts/quickFixes/typeAssertPropertyAccessToAny.ts +++ b/lib/main/lang/fixmyts/quickFixes/typeAssertPropertyAccessToAny.ts @@ -19,15 +19,16 @@ export class TypeAssertPropertyAccessToAny implements QuickFix { } provideFix(info: QuickFixQueryInformation): Refactoring[] { - /** - * We want the largest property access expressing `a.b.c` starting at the identifer `c` - * Since this gets tokenized as `a.b` `.` `c` so its just the parent :) - */ let parent = info.positionNode.parent; if (parent.kind == ts.SyntaxKind.PropertyAccessExpression) { let propertyAccess = parent; + + // Find the previous identifier skipping over the DotToken + let idx = propertyAccess.getChildren().indexOf(info.positionNode) + let prev = propertyAccess.getChildAt(idx-2); + let start = propertyAccess.getStart(); - let end = propertyAccess.dotToken.getStart(); + let end = prev.getEnd(); let oldText = propertyAccess.getText().substr(0, end - start); diff --git a/lib/main/lang/fixmyts/quickFixes/typeAssertPropertyAccessToType.ts b/lib/main/lang/fixmyts/quickFixes/typeAssertPropertyAccessToType.ts index 653d23c0b..4318dcf9a 100644 --- a/lib/main/lang/fixmyts/quickFixes/typeAssertPropertyAccessToType.ts +++ b/lib/main/lang/fixmyts/quickFixes/typeAssertPropertyAccessToType.ts @@ -19,15 +19,16 @@ export class TypeAssertPropertyAccessToType implements QuickFix { } provideFix(info: QuickFixQueryInformation): Refactoring[] { - /** - * We want the largest property access expressing `a.b.c` starting at the identifer `c` - * Since this gets tokenized as `a.b` `.` `c` so its just the parent :) - */ let parent = info.positionNode.parent; if (parent.kind == ts.SyntaxKind.PropertyAccessExpression) { let propertyAccess = parent; + + // Find the previous identifier skipping over the DotToken + let idx = propertyAccess.getChildren().indexOf(info.positionNode) + let prev = propertyAccess.getChildAt(idx-2); + let start = propertyAccess.getStart(); - let end = propertyAccess.dotToken.getStart(); + let end = prev.getEnd(); let oldText = propertyAccess.getText().substr(0, end - start); diff --git a/lib/main/tsconfig/simpleValidator.ts b/lib/main/tsconfig/simpleValidator.ts index 92628f1b4..40f7f0290 100644 --- a/lib/main/tsconfig/simpleValidator.ts +++ b/lib/main/tsconfig/simpleValidator.ts @@ -1,11 +1,12 @@ /// Not useful for user input validation -// But great for simple config validation +// But great for simple config validation // works only by "n" valid options export var types = { string: 'string', boolean: 'boolean', - number: 'number' + number: 'number', + object: 'object' } export interface ValidationInfo { @@ -41,7 +42,7 @@ export class SimpleValidator { else { errors.extraKeys.push(`Unknown Option: ${k}`) } - } + } // Do validation else { var validationInfo = this.validationInfo[k]; diff --git a/lib/main/tsconfig/tsconfig.ts b/lib/main/tsconfig/tsconfig.ts index 39e15737c..b2761c061 100644 --- a/lib/main/tsconfig/tsconfig.ts +++ b/lib/main/tsconfig/tsconfig.ts @@ -40,6 +40,9 @@ interface CompilerOptions { mapRoot?: string; // Optionally Specifies the location where debugger should locate map files after deployment module?: string; moduleResolution?: string; + baseUrl?: string; + paths?: { [pattern: string]: string[] }; + rootDirs?: string[]; newLine?: string; noEmit?: boolean; noEmitHelpers?: boolean; @@ -97,6 +100,9 @@ var compilerOptionsValidation: simpleValidator.ValidationInfo = { mapRoot: { type: types.string }, module: { type: types.string, validValues: ['commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'] }, moduleResolution: { type: types.string, validValues: ['classic', 'node'] }, + baseUrl: { type: types.string }, + paths: { type: types.object }, + rootDirs: { type: types.object }, newLine: { type: types.string }, noEmit: { type: types.boolean }, noEmitHelpers: { type: types.boolean }, @@ -336,6 +342,16 @@ function rawToTsCompilerOptions(jsonOptions: CompilerOptions, projectDir: string compilerOptions.outFile = path.resolve(projectDir, compilerOptions.outFile); } + if (compilerOptions.baseUrl !== undefined) { + compilerOptions.baseUrl = path.resolve(projectDir, compilerOptions.baseUrl); + } + + if (compilerOptions.rootDirs !== undefined && Array.isArray(compilerOptions.rootDirs)) { + compilerOptions.rootDirs = compilerOptions.rootDirs.map(function(dir) { + return path.resolve(projectDir, dir) + }); + } + return compilerOptions; } diff --git a/lib/typings/d3/d3.d.ts b/lib/typings/d3/d3.d.ts index 541615d64..0e5cddaae 100644 --- a/lib/typings/d3/d3.d.ts +++ b/lib/typings/d3/d3.d.ts @@ -835,7 +835,7 @@ declare module D3 { * to compare, and should return either a negative, positive, or zero value to indicate * their relative order. */ - sort(comparator?: (a: T, b: T) => number): _Selection; + sort(comparator?: (a: T, b: T) => number): this; /** * Re-inserts elements into the document such that the document order matches the selection diff --git a/package.json b/package.json index db8c00802..cb2e4f809 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "immutable": "^3.7.3", "json2dts": "0.0.1", "mkdirp": "^0.5.0", - "ntypescript": "1.201604232306.1", + "ntypescript": "1.201607050909.1", "react": "^0.13.3", "season": "^5.1.4", "tsconfig": "^2.2.0",