Skip to content

Commit

Permalink
feat(ts): support 2.2.0
Browse files Browse the repository at this point in the history
Fix #149
  • Loading branch information
mgechev committed Dec 10, 2016
1 parent 20ce61a commit 28059b1
Show file tree
Hide file tree
Showing 2 changed files with 372 additions and 0 deletions.
331 changes: 331 additions & 0 deletions src/util/syntaxKind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2458,6 +2458,335 @@ module SyntaxKind {
LastJSDocTagNode: 291
};

var SyntaxKind_2_2: SyntaxKind = {
Unknown: 0,
EndOfFileToken: 1,
SingleLineCommentTrivia: 2,
MultiLineCommentTrivia: 3,
NewLineTrivia: 4,
WhitespaceTrivia: 5,
ShebangTrivia: 6,
ConflictMarkerTrivia: 7,
NumericLiteral: 8,
StringLiteral: 9,
JsxText: 10,
RegularExpressionLiteral: 11,
NoSubstitutionTemplateLiteral: 12,
TemplateHead: 13,
TemplateMiddle: 14,
TemplateTail: 15,
OpenBraceToken: 16,
CloseBraceToken: 17,
OpenParenToken: 18,
CloseParenToken: 19,
OpenBracketToken: 20,
CloseBracketToken: 21,
DotToken: 22,
DotDotDotToken: 23,
SemicolonToken: 24,
CommaToken: 25,
LessThanToken: 26,
LessThanSlashToken: 27,
GreaterThanToken: 28,
LessThanEqualsToken: 29,
GreaterThanEqualsToken: 30,
EqualsEqualsToken: 31,
ExclamationEqualsToken: 32,
EqualsEqualsEqualsToken: 33,
ExclamationEqualsEqualsToken: 34,
EqualsGreaterThanToken: 35,
PlusToken: 36,
MinusToken: 37,
AsteriskToken: 38,
AsteriskAsteriskToken: 39,
SlashToken: 40,
PercentToken: 41,
PlusPlusToken: 42,
MinusMinusToken: 43,
LessThanLessThanToken: 44,
GreaterThanGreaterThanToken: 45,
GreaterThanGreaterThanGreaterThanToken: 46,
AmpersandToken: 47,
BarToken: 48,
CaretToken: 49,
ExclamationToken: 50,
TildeToken: 51,
AmpersandAmpersandToken: 52,
BarBarToken: 53,
QuestionToken: 54,
ColonToken: 55,
AtToken: 56,
EqualsToken: 57,
PlusEqualsToken: 58,
MinusEqualsToken: 59,
AsteriskEqualsToken: 60,
AsteriskAsteriskEqualsToken: 61,
SlashEqualsToken: 62,
PercentEqualsToken: 63,
LessThanLessThanEqualsToken: 64,
GreaterThanGreaterThanEqualsToken: 65,
GreaterThanGreaterThanGreaterThanEqualsToken: 66,
AmpersandEqualsToken: 67,
BarEqualsToken: 68,
CaretEqualsToken: 69,
Identifier: 70,
BreakKeyword: 71,
CaseKeyword: 72,
CatchKeyword: 73,
ClassKeyword: 74,
ConstKeyword: 75,
ContinueKeyword: 76,
DebuggerKeyword: 77,
DefaultKeyword: 78,
DeleteKeyword: 79,
DoKeyword: 80,
ElseKeyword: 81,
EnumKeyword: 82,
ExportKeyword: 83,
ExtendsKeyword: 84,
FalseKeyword: 85,
FinallyKeyword: 86,
ForKeyword: 87,
FunctionKeyword: 88,
IfKeyword: 89,
ImportKeyword: 90,
InKeyword: 91,
InstanceOfKeyword: 92,
NewKeyword: 93,
NullKeyword: 94,
ReturnKeyword: 95,
SuperKeyword: 96,
SwitchKeyword: 97,
ThisKeyword: 98,
ThrowKeyword: 99,
TrueKeyword: 100,
TryKeyword: 101,
TypeOfKeyword: 102,
VarKeyword: 103,
VoidKeyword: 104,
WhileKeyword: 105,
WithKeyword: 106,
ImplementsKeyword: 107,
InterfaceKeyword: 108,
LetKeyword: 109,
PackageKeyword: 110,
PrivateKeyword: 111,
ProtectedKeyword: 112,
PublicKeyword: 113,
StaticKeyword: 114,
YieldKeyword: 115,
AbstractKeyword: 116,
AsKeyword: 117,
AnyKeyword: 118,
AsyncKeyword: 119,
AwaitKeyword: 120,
BooleanKeyword: 121,
ConstructorKeyword: 122,
DeclareKeyword: 123,
GetKeyword: 124,
IsKeyword: 125,
KeyOfKeyword: 126,
ModuleKeyword: 127,
NamespaceKeyword: 128,
NeverKeyword: 129,
ReadonlyKeyword: 130,
RequireKeyword: 131,
NumberKeyword: 132,
SetKeyword: 133,
StringKeyword: 134,
SymbolKeyword: 135,
TypeKeyword: 136,
UndefinedKeyword: 137,
FromKeyword: 138,
GlobalKeyword: 139,
OfKeyword: 140,
QualifiedName: 141,
ComputedPropertyName: 142,
TypeParameter: 143,
Parameter: 144,
Decorator: 145,
PropertySignature: 146,
PropertyDeclaration: 147,
MethodSignature: 148,
MethodDeclaration: 149,
Constructor: 150,
GetAccessor: 151,
SetAccessor: 152,
CallSignature: 153,
ConstructSignature: 154,
IndexSignature: 155,
TypePredicate: 156,
TypeReference: 157,
FunctionType: 158,
ConstructorType: 159,
TypeQuery: 160,
TypeLiteral: 161,
ArrayType: 162,
TupleType: 163,
UnionType: 164,
IntersectionType: 165,
ParenthesizedType: 166,
ThisType: 167,
TypeOperator: 168,
IndexedAccessType: 169,
MappedType: 170,
LiteralType: 171,
ObjectBindingPattern: 172,
ArrayBindingPattern: 173,
BindingElement: 174,
ArrayLiteralExpression: 175,
ObjectLiteralExpression: 176,
PropertyAccessExpression: 177,
ElementAccessExpression: 178,
CallExpression: 179,
NewExpression: 180,
TaggedTemplateExpression: 181,
TypeAssertionExpression: 182,
ParenthesizedExpression: 183,
FunctionExpression: 184,
ArrowFunction: 185,
DeleteExpression: 186,
TypeOfExpression: 187,
VoidExpression: 188,
AwaitExpression: 189,
PrefixUnaryExpression: 190,
PostfixUnaryExpression: 191,
BinaryExpression: 192,
ConditionalExpression: 193,
TemplateExpression: 194,
YieldExpression: 195,
SpreadElement: 196,
ClassExpression: 197,
OmittedExpression: 198,
ExpressionWithTypeArguments: 199,
AsExpression: 200,
NonNullExpression: 201,
TemplateSpan: 202,
SemicolonClassElement: 203,
Block: 204,
VariableStatement: 205,
EmptyStatement: 206,
ExpressionStatement: 207,
IfStatement: 208,
DoStatement: 209,
WhileStatement: 210,
ForStatement: 211,
ForInStatement: 212,
ForOfStatement: 213,
ContinueStatement: 214,
BreakStatement: 215,
ReturnStatement: 216,
WithStatement: 217,
SwitchStatement: 218,
LabeledStatement: 219,
ThrowStatement: 220,
TryStatement: 221,
DebuggerStatement: 222,
VariableDeclaration: 223,
VariableDeclarationList: 224,
FunctionDeclaration: 225,
ClassDeclaration: 226,
InterfaceDeclaration: 227,
TypeAliasDeclaration: 228,
EnumDeclaration: 229,
ModuleDeclaration: 230,
ModuleBlock: 231,
CaseBlock: 232,
NamespaceExportDeclaration: 233,
ImportEqualsDeclaration: 234,
ImportDeclaration: 235,
ImportClause: 236,
NamespaceImport: 237,
NamedImports: 238,
ImportSpecifier: 239,
ExportAssignment: 240,
ExportDeclaration: 241,
NamedExports: 242,
ExportSpecifier: 243,
MissingDeclaration: 244,
ExternalModuleReference: 245,
JsxElement: 246,
JsxSelfClosingElement: 247,
JsxOpeningElement: 248,
JsxClosingElement: 249,
JsxAttribute: 250,
JsxSpreadAttribute: 251,
JsxExpression: 252,
CaseClause: 253,
DefaultClause: 254,
HeritageClause: 255,
CatchClause: 256,
PropertyAssignment: 257,
ShorthandPropertyAssignment: 258,
SpreadAssignment: 259,
EnumMember: 260,
SourceFile: 261,
JSDocTypeExpression: 262,
JSDocAllType: 263,
JSDocUnknownType: 264,
JSDocArrayType: 265,
JSDocUnionType: 266,
JSDocTupleType: 267,
JSDocNullableType: 268,
JSDocNonNullableType: 269,
JSDocRecordType: 270,
JSDocRecordMember: 271,
JSDocTypeReference: 272,
JSDocOptionalType: 273,
JSDocFunctionType: 274,
JSDocVariadicType: 275,
JSDocConstructorType: 276,
JSDocThisType: 277,
JSDocComment: 278,
JSDocTag: 279,
JSDocParameterTag: 280,
JSDocReturnTag: 281,
JSDocTypeTag: 282,
JSDocTemplateTag: 283,
JSDocTypedefTag: 284,
JSDocPropertyTag: 285,
JSDocTypeLiteral: 286,
JSDocLiteralType: 287,
JSDocNullKeyword: 288,
JSDocUndefinedKeyword: 289,
JSDocNeverKeyword: 290,
SyntaxList: 291,
NotEmittedStatement: 292,
PartiallyEmittedExpression: 293,
MergeDeclarationMarker: 294,
EndOfDeclarationMarker: 295,
Count: 296,
FirstAssignment: 57,
LastAssignment: 69,
FirstCompoundAssignment: 58,
LastCompoundAssignment: 69,
FirstReservedWord: 71,
LastReservedWord: 106,
FirstKeyword: 71,
LastKeyword: 140,
FirstFutureReservedWord: 107,
LastFutureReservedWord: 115,
FirstTypeNode: 156,
LastTypeNode: 171,
FirstPunctuation: 16,
LastPunctuation: 69,
FirstToken: 0,
LastToken: 140,
FirstTriviaToken: 2,
LastTriviaToken: 7,
FirstLiteralToken: 8,
LastLiteralToken: 12,
FirstTemplateToken: 12,
LastTemplateToken: 15,
FirstBinaryOperator: 26,
LastBinaryOperator: 69,
FirstNode: 141,
FirstJSDocNode: 262,
LastJSDocNode: 287,
FirstJSDocTagNode: 278,
LastJSDocTagNode: 290,
};

export function current(): SyntaxKind.SyntaxKind {
if (cachedKinds === null) {
if (/1\.5\..*/.test(ts.version)) {
Expand All @@ -2474,6 +2803,8 @@ module SyntaxKind {
cachedKinds = SyntaxKind_2_0;
} else if (/2\.1\..*/.test(ts.version)) {
cachedKinds = SyntaxKind_2_1;
} else if (/2\.2\..*/.test(ts.version)) {
cachedKinds = SyntaxKind_2_2;
} else {
throw new Error('Unsupported TypeScript version: ' + ts.version);
}
Expand Down
41 changes: 41 additions & 0 deletions test/angular/ng2Walker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,47 @@ describe('ng2Walker', () => {
}).not.to.throw();
});

it('should not break', () => {
let source = `
export class Main {
constructor() {
}
regExp() {
// complaining about missing whitespace after coma in regex
const test = /\${0,1}/.test('not important$');
console.log(test);
}
stringLiteral() {
const offset = "3";
// complaining about missing whitespace inside of string literal
const test = \`<path d="M\${offset},\${offset}">\`;
console.log(test);
}
}
// compains about missing semicolon at end
export class WantsSemiColonAtEndOfClass {
constructor() {
}
}
`;
let ruleArgs: tslint.IOptions = {
ruleName: 'foo',
ruleArguments: ['foo'],
disabledIntervals: null
};
let sf = ts.createSourceFile('foo', source, null);
let walker = new Ng2Walker(sf, ruleArgs);
(<any>chai).expect(() => {
walker.walk(sf);
}).not.to.throw();
});

});

});
Expand Down

0 comments on commit 28059b1

Please sign in to comment.