Skip to content

Commit f0b411e

Browse files
committed
Different workaround for microsoft/TypeScript#12083
1 parent 3e15991 commit f0b411e

File tree

5 files changed

+16
-13
lines changed

5 files changed

+16
-13
lines changed

src/parser/cssNodes.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ export class Node {
371371
}
372372

373373
export class Nodelist extends Node {
374+
private _nodeList: void; // workaround for https://github.com/Microsoft/TypeScript/issues/12083
374375

375376
constructor(parent: Node, index: number = -1) {
376377
super(-1, -1);
@@ -470,6 +471,8 @@ export class RuleSet extends BodyDeclaration {
470471

471472
export class Selector extends Node {
472473

474+
private _selector: void; // workaround for https://github.com/Microsoft/TypeScript/issues/12083
475+
473476
constructor(offset: number, length: number) {
474477
super(offset, length);
475478
}
@@ -482,6 +485,8 @@ export class Selector extends Node {
482485

483486
export class SimpleSelector extends Node {
484487

488+
private _simpleSelector: void; // workaround for https://github.com/Microsoft/TypeScript/issues/12083
489+
485490
constructor(offset: number, length: number) {
486491
super(offset, length);
487492
}
@@ -990,6 +995,8 @@ export class PageBoxMarginBox extends BodyDeclaration {
990995

991996
export class Expression extends Node {
992997

998+
private _expression: void; // workaround for https://github.com/Microsoft/TypeScript/issues/12083
999+
9931000
constructor(offset: number, length: number) {
9941001
super(offset, length);
9951002
}

src/parser/cssParser.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ export class Parser {
132132
if (this.prevToken !== null) {
133133
// length with more elements belonging together
134134
let prevEnd = this.prevToken.offset + this.prevToken.len;
135-
let node2 = <nodes.Node> node; // workaround for https://github.com/Microsoft/TypeScript/issues/12083
136-
node2.length = prevEnd > node2.offset ? prevEnd - node2.offset : 0; // offset is taken from current token, end from previous: Use 0 for empty nodes
135+
node.length = prevEnd > node.offset ? prevEnd - node.offset : 0; // offset is taken from current token, end from previous: Use 0 for empty nodes
137136
}
138137

139138
}

src/services/cssCompletion.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,15 @@ export class CSSCompletion {
4747

4848
for (let i = this.nodePath.length - 1; i >= 0; i--) {
4949
let node = this.nodePath[i];
50-
let node2 = node; // workaround for https://github.com/Microsoft/TypeScript/issues/12083
5150
if (node instanceof nodes.Property) {
5251
this.getCompletionsForDeclarationProperty(node.getParent() as nodes.Declaration, result);
5352
} else if (node instanceof nodes.Expression) {
5453
this.getCompletionsForExpression(<nodes.Expression>node, result);
5554
} else if (node instanceof nodes.SimpleSelector) {
56-
let parentRuleSet = <nodes.RuleSet>node2.findParent(nodes.NodeType.Ruleset);
55+
let parentRuleSet = <nodes.RuleSet>node.findParent(nodes.NodeType.Ruleset);
5756
this.getCompletionsForSelector(parentRuleSet, result);
57+
} else if (node instanceof nodes.FunctionArgument) {
58+
this.getCompletionsForFunctionArgument(<nodes.FunctionArgument>node, <nodes.Function>node.getParent(), result);
5859
} else if (node instanceof nodes.Declarations) {
5960
this.getCompletionsForDeclarations(<nodes.Declarations>node, result);
6061
} else if (node instanceof nodes.VariableDeclaration) {
@@ -63,8 +64,6 @@ export class CSSCompletion {
6364
this.getCompletionsForRuleSet(<nodes.RuleSet>node, result);
6465
} else if (node instanceof nodes.Interpolation) {
6566
this.getCompletionsForInterpolation(<nodes.Interpolation>node, result);
66-
} else if (node instanceof nodes.FunctionArgument) {
67-
this.getCompletionsForFunctionArgument(<nodes.FunctionArgument>node, <nodes.Function>node2.getParent(), result);
6867
} else if (node instanceof nodes.FunctionDeclaration) {
6968
this.getCompletionsForFunctionDeclaration(<nodes.FunctionDeclaration>node, result);
7069
} else if (node instanceof nodes.Function) {
@@ -148,7 +147,7 @@ export class CSSCompletion {
148147
public getCompletionsForDeclarationValue(node: nodes.Declaration, result: CompletionList): CompletionList {
149148
let propertyName = node.getFullPropertyName();
150149
let entry = languageFacts.getProperties()[propertyName];
151-
let existingNode = node.getValue();
150+
let existingNode: nodes.Node = node.getValue();
152151

153152
while (existingNode && existingNode.hasChildren()) {
154153
existingNode = existingNode.findChildAtOffset(this.offset, false);

src/services/cssHover.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class CSSHover {
3838
};
3939
}
4040
if (node instanceof nodes.Declaration) {
41-
let propertyName = (<nodes.Declaration> node).getFullPropertyName(); // workaround for https://github.com/Microsoft/TypeScript/issues/12083
41+
let propertyName = node.getFullPropertyName();
4242
let entry = languageFacts.getProperties()[propertyName];
4343
if (entry) {
4444
let contents : MarkedString[] = [];

src/services/selectorPrinting.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,7 @@ class SelectorElementBuilder {
308308
selector.getChildren().forEach(selectorChild => {
309309

310310
if (selectorChild instanceof nodes.SimpleSelector) {
311-
let prev2 = this.prev; // workaround for https://github.com/Microsoft/TypeScript/issues/12083
312-
if (prev2 instanceof nodes.SimpleSelector) {
311+
if (this.prev instanceof nodes.SimpleSelector) {
313312
let labelElement = new LabelElement('\u2026');
314313
this.element.addChild(labelElement);
315314
this.element = labelElement;
@@ -328,8 +327,7 @@ class SelectorElementBuilder {
328327
this.element.addChild(root);
329328
this.element = thisElement;
330329
}
331-
var selectorChild2 = selectorChild; // workaround for https://github.com/Microsoft/TypeScript/issues/12083
332-
if (selectorChild2 instanceof nodes.SimpleSelector ||
330+
if (selectorChild instanceof nodes.SimpleSelector ||
333331
selectorChild.type === nodes.NodeType.SelectorCombinatorParent ||
334332
selectorChild.type === nodes.NodeType.SelectorCombinatorSibling ||
335333
selectorChild.type === nodes.NodeType.SelectorCombinatorAllSiblings) {
@@ -372,7 +370,7 @@ export function selectorToElement(node: nodes.Selector): Element {
372370
let builder = new SelectorElementBuilder(root);
373371

374372
for (let i = parentRuleSets.length - 1; i >= 0; i--) {
375-
let selector = parentRuleSets[i].getSelectors().getChild(0);
373+
let selector = <nodes.Selector> parentRuleSets[i].getSelectors().getChild(0);
376374
if (selector) {
377375
builder.processSelector(selector);
378376
}

0 commit comments

Comments
 (0)