Skip to content

Allow using baseUrl, paths and rootDirs options in tsconfig,json #996

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

Merged
merged 6 commits into from
Jul 13, 2016
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
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion dist/main/tsconfig/simpleValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
exports.types = {
string: 'string',
boolean: 'boolean',
number: 'number'
number: 'number',
object: 'object'
};
var SimpleValidator = (function () {
function SimpleValidator(validationInfo) {
Expand Down
11 changes: 11 additions & 0 deletions dist/main/tsconfig/tsconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <ts.PropertyAccessExpression>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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <ts.PropertyAccessExpression>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);

Expand Down
7 changes: 4 additions & 3 deletions lib/main/tsconfig/simpleValidator.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -41,7 +42,7 @@ export class SimpleValidator {
else {
errors.extraKeys.push(`Unknown Option: ${k}`)
}
}
}
// Do validation
else {
var validationInfo = this.validationInfo[k];
Expand Down
16 changes: 16 additions & 0 deletions lib/main/tsconfig/tsconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 },
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/typings/d3/d3.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>;
sort(comparator?: (a: T, b: T) => number): this;

/**
* Re-inserts elements into the document such that the document order matches the selection
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down