Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion docs/codeql/support/reusables/versions-compilers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
JavaScript,ECMAScript 2022 or lower,Not applicable,"``.js``, ``.jsx``, ``.mjs``, ``.es``, ``.es6``, ``.htm``, ``.html``, ``.xhtm``, ``.xhtml``, ``.vue``, ``.hbs``, ``.ejs``, ``.njk``, ``.json``, ``.yaml``, ``.yml``, ``.raml``, ``.xml`` [6]_"
Python,"2.7, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10",Not applicable,``.py``
Ruby [7]_,"up to 3.0.2",Not applicable,"``.rb``, ``.erb``, ``.gemspec``, ``Gemfile``"
TypeScript [8]_,"2.6-4.7",Standard TypeScript compiler,"``.ts``, ``.tsx``, ``.mts``, ``.cts``"
TypeScript [8]_,"2.6-4.8",Standard TypeScript compiler,"``.ts``, ``.tsx``, ``.mts``, ``.cts``"

.. container:: footnote-group

Expand Down
2 changes: 1 addition & 1 deletion javascript/extractor/lib/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "typescript-parser-wrapper",
"private": true,
"dependencies": {
"typescript": "4.7.2"
"typescript": "4.8.2"
},
"scripts": {
"build": "tsc --project tsconfig.json",
Expand Down
6 changes: 6 additions & 0 deletions javascript/extractor/lib/typescript/src/ast_extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@ export function augmentAst(ast: AugmentedSourceFile, code: string, project: Proj
}
}

// This PR: https://github.com/microsoft/TypeScript/pull/50343/ changed how illegal decorators are stored, this hack reverts it.
// Those decorator uses are syntax errors, but people use them anyway.
if ((node as any).illegalDecorators) {
(node as any).decorators = (node as any).illegalDecorators;
}

if (typeChecker != null && insideConditionalTypes === 0) {
if (isTypedNode(node)) {
let contextualType = isContextuallyTypedNode(node)
Expand Down
2 changes: 1 addition & 1 deletion javascript/extractor/lib/typescript/src/type_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ export class TypeTable {
* Returns a unique string for the given call/constructor signature.
*/
private getSignatureString(kind: ts.SignatureKind, signature: AugmentedSignature): string {
let modifiers : ts.ModifiersArray = signature.getDeclaration()?.modifiers;
let modifiers = signature.getDeclaration()?.modifiers;
let isAbstract = modifiers && modifiers.filter(modifier => modifier.kind == ts.SyntaxKind.AbstractKeyword).length > 0

let parameters = signature.getParameters();
Expand Down
8 changes: 4 additions & 4 deletions javascript/extractor/lib/typescript/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
version "12.7.11"
resolved node-12.7.11.tgz#be879b52031cfb5d295b047f5462d8ef1a716446

typescript@4.7.2:
version "4.7.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.2.tgz#1f9aa2ceb9af87cca227813b4310fff0b51593c4"
integrity sha512-Mamb1iX2FDUpcTRzltPxgWMKy3fhg0TN378ylbktPGPK/99KbDtMQ4W1hwgsbPAsG3a0xKa1vmw4VKZQbkvz5A==
typescript@4.8.2:
version "4.8.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.2.tgz#e3b33d5ccfb5914e4eeab6699cf208adee3fd790"
integrity sha512-C0I1UsrrDHo2fYI5oaCGbSejwX4ch+9Y5jTQELvovfmFkK3HHSZJB8MSJcWLmCUBzQBchCrZ9rMRV6GuNrvGtw==
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class Main {
* A version identifier that should be updated every time the extractor changes in such a way that
* it may produce different tuples for the same file under the same {@link ExtractorConfig}.
*/
public static final String EXTRACTOR_VERSION = "2022-07-11";
public static final String EXTRACTOR_VERSION = "2022-08-25";

public static final Pattern NEWLINE = Pattern.compile("\n");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -976,8 +976,9 @@ private Node convertClass(JsonObject node, String kind, SourceLocation loc) thro
hasDeclareKeyword,
hasAbstractKeyword);
attachSymbolInformation(classDecl.getClassDef(), node);
if (node.has("decorators")) {
classDecl.addDecorators(convertChildren(node, "decorators"));
List<Decorator> decorators = getDecorators(node);
if (!decorators.isEmpty()) {
classDecl.addDecorators(decorators);
advanceUntilAfter(loc, classDecl.getDecorators());
}
Node exportedDecl = fixExports(loc, classDecl);
Expand All @@ -989,6 +990,17 @@ private Node convertClass(JsonObject node, String kind, SourceLocation loc) thro
return exportedDecl;
}

List<Decorator> getDecorators(JsonObject node) throws ParseError {
List<Decorator> result = new ArrayList<>();
for (JsonElement elt : getChildIterable(node, "modifiers")) {
JsonObject modifier = elt.getAsJsonObject();
if (hasKind(modifier, "Decorator")) {
result.add((Decorator) convertNode(modifier));
}
}
return result;
}

private Node convertCommaListExpression(JsonObject node, SourceLocation loc) throws ParseError {
return new SequenceExpression(loc, convertChildren(node, "elements"));
}
Expand Down Expand Up @@ -1041,7 +1053,7 @@ private DecoratorList makeDecoratorList(JsonElement decorators) throws ParseErro
private List<DecoratorList> convertParameterDecorators(JsonObject function) throws ParseError {
List<DecoratorList> decoratorLists = new ArrayList<>();
for (JsonElement parameter : getProperParameters(function)) {
decoratorLists.add(makeDecoratorList(parameter.getAsJsonObject().get("decorators")));
decoratorLists.add(makeDecoratorList(parameter.getAsJsonObject().get("modifiers")));
}
return decoratorLists;
}
Expand Down Expand Up @@ -1664,8 +1676,9 @@ private Node convertMethodDeclaration(JsonObject node, String kind, SourceLocati
FunctionExpression method = convertImplicitFunction(node, loc);
MethodDefinition methodDefinition =
new MethodDefinition(loc, flags, methodKind, convertChild(node, "name"), method);
if (node.has("decorators")) {
methodDefinition.addDecorators(convertChildren(node, "decorators"));
List<Decorator> decorators = getDecorators(node);
if (!decorators.isEmpty()) {
methodDefinition.addDecorators(decorators);
advanceUntilAfter(loc, methodDefinition.getDecorators());
}
return methodDefinition;
Expand Down Expand Up @@ -2079,8 +2092,9 @@ private Node convertPropertyDeclaration(JsonObject node, String kind, SourceLoca
convertChild(node, "name"),
convertChild(node, "initializer"),
convertChildAsType(node, "type"));
if (node.has("decorators")) {
fieldDefinition.addDecorators(convertChildren(node, "decorators"));
List<Decorator> decorators = getDecorators(node);
if (!decorators.isEmpty()) {
fieldDefinition.addDecorators(decorators);
advanceUntilAfter(loc, fieldDefinition.getDecorators());
}
return fieldDefinition;
Expand Down
4 changes: 4 additions & 0 deletions javascript/ql/lib/change-notes/2022-05-24-typescript-4-8.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
category: majorAnalysis
---
* Added support for TypeScript 4.8.
Loading