Skip to content

Commit

Permalink
Implement ALL THE TYPE BUILDERS
Browse files Browse the repository at this point in the history
  • Loading branch information
weswigham committed Jul 26, 2016
1 parent a32234c commit 42e76e8
Show file tree
Hide file tree
Showing 6 changed files with 1,628 additions and 44 deletions.
3 changes: 2 additions & 1 deletion Jakefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ var harnessSources = harnessCoreSources.concat([
"convertCompilerOptionsFromJson.ts",
"convertTypingOptionsFromJson.ts",
"tsserverProjectSystem.ts",
"matchFiles.ts"
"matchFiles.ts",
"typeBuilder.ts",
].map(function (f) {
return path.join(unittestsDirectory, f);
})).concat([
Expand Down
20 changes: 12 additions & 8 deletions scripts/tslint/typeOperatorSpacingRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,19 @@ export class Rule extends Lint.Rules.AbstractRule {
class TypeOperatorSpacingWalker extends Lint.RuleWalker {
public visitNode(node: ts.Node) {
if (node.kind === ts.SyntaxKind.UnionType || node.kind === ts.SyntaxKind.IntersectionType) {
const types = (<ts.UnionOrIntersectionTypeNode>node).types;
let expectedStart = types[0].end + 2; // space, | or &
for (let i = 1; i < types.length; i++) {
const currentType = types[i];
if (expectedStart !== currentType.pos || currentType.getLeadingTriviaWidth() !== 1) {
const failure = this.createFailure(currentType.pos, currentType.getWidth(), Rule.FAILURE_STRING);
this.addFailure(failure);
const {line: start} = ts.getLineAndCharacterOfPosition(this.getSourceFile(), node.getStart());
const {line: end} = ts.getLineAndCharacterOfPosition(this.getSourceFile(), node.getEnd());
if (start === end) {
const types = (<ts.UnionOrIntersectionTypeNode>node).types;
let expectedStart = types[0].end + 2; // space, | or &
for (let i = 1; i < types.length; i++) {
const currentType = types[i];
if (expectedStart !== currentType.pos || currentType.getLeadingTriviaWidth() !== 1) {
const failure = this.createFailure(currentType.pos, currentType.getWidth(), Rule.FAILURE_STRING);
this.addFailure(failure);
}
expectedStart = currentType.end + 2;
}
expectedStart = currentType.end + 2;
}
}
super.visitNode(node);
Expand Down
Loading

0 comments on commit 42e76e8

Please sign in to comment.