Skip to content

Commit 42e76e8

Browse files
committed
Implement ALL THE TYPE BUILDERS
1 parent a32234c commit 42e76e8

File tree

6 files changed

+1628
-44
lines changed

6 files changed

+1628
-44
lines changed

Jakefile.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ var harnessSources = harnessCoreSources.concat([
158158
"convertCompilerOptionsFromJson.ts",
159159
"convertTypingOptionsFromJson.ts",
160160
"tsserverProjectSystem.ts",
161-
"matchFiles.ts"
161+
"matchFiles.ts",
162+
"typeBuilder.ts",
162163
].map(function (f) {
163164
return path.join(unittestsDirectory, f);
164165
})).concat([

scripts/tslint/typeOperatorSpacingRule.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,19 @@ export class Rule extends Lint.Rules.AbstractRule {
1313
class TypeOperatorSpacingWalker extends Lint.RuleWalker {
1414
public visitNode(node: ts.Node) {
1515
if (node.kind === ts.SyntaxKind.UnionType || node.kind === ts.SyntaxKind.IntersectionType) {
16-
const types = (<ts.UnionOrIntersectionTypeNode>node).types;
17-
let expectedStart = types[0].end + 2; // space, | or &
18-
for (let i = 1; i < types.length; i++) {
19-
const currentType = types[i];
20-
if (expectedStart !== currentType.pos || currentType.getLeadingTriviaWidth() !== 1) {
21-
const failure = this.createFailure(currentType.pos, currentType.getWidth(), Rule.FAILURE_STRING);
22-
this.addFailure(failure);
16+
const {line: start} = ts.getLineAndCharacterOfPosition(this.getSourceFile(), node.getStart());
17+
const {line: end} = ts.getLineAndCharacterOfPosition(this.getSourceFile(), node.getEnd());
18+
if (start === end) {
19+
const types = (<ts.UnionOrIntersectionTypeNode>node).types;
20+
let expectedStart = types[0].end + 2; // space, | or &
21+
for (let i = 1; i < types.length; i++) {
22+
const currentType = types[i];
23+
if (expectedStart !== currentType.pos || currentType.getLeadingTriviaWidth() !== 1) {
24+
const failure = this.createFailure(currentType.pos, currentType.getWidth(), Rule.FAILURE_STRING);
25+
this.addFailure(failure);
26+
}
27+
expectedStart = currentType.end + 2;
2328
}
24-
expectedStart = currentType.end + 2;
2529
}
2630
}
2731
super.visitNode(node);

0 commit comments

Comments
 (0)