Skip to content

Commit 847faf5

Browse files
authored
Merge pull request github#6070 from asgerf/js/script-with-tsx-lang
Approved by erik-krogh
2 parents 87ee784 + 53bef94 commit 847faf5

File tree

6 files changed

+31
-8
lines changed

6 files changed

+31
-8
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
lgtm,codescanning
2+
* Script tags with the `lang="tsx"` attribute are now recognized as containing TypeScript code
3+
and are analyzed accordingly.

javascript/extractor/src/com/semmle/js/extractor/HTMLExtractor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ private String getScriptLanguage(Element script) {
271271

272272
private boolean isTypeScriptTag(Element script) {
273273
String language = getScriptLanguage(script);
274-
if ("ts".equals(language) || "typescript".equals(language)) return true;
274+
if ("ts".equals(language) || "tsx".equals(language) || "typescript".equals(language)) return true;
275275
String type = getAttributeValueLC(script, "type");
276276
if (type != null && type.contains("typescript")) return true;
277277
return false;

javascript/extractor/src/com/semmle/js/extractor/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class Main {
4343
* A version identifier that should be updated every time the extractor changes in such a way that
4444
* it may produce different tuples for the same file under the same {@link ExtractorConfig}.
4545
*/
46-
public static final String EXTRACTOR_VERSION = "2021-05-31";
46+
public static final String EXTRACTOR_VERSION = "2021-06-15";
4747

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

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
classDeclaration
22
| test.vue:3:18:5:3 | class M ... er;\\n } |
3+
| test_tsx.vue:3:18:5:3 | class M ... er;\\n } |
34
exprType
45
| htmlfile.html:4:22:4:24 | foo | () => void |
56
| htmlfile.html:4:22:4:24 | foo | () => void |
@@ -10,17 +11,28 @@ exprType
1011
| htmlfile.html:5:26:5:42 | foo() as number[] | number[] |
1112
| other.ts:1:8:1:16 | Component | typeof default in library-tests/TypeScript/EmbeddedInScript/test.vue |
1213
| other.ts:1:23:1:34 | "./test.vue" | any |
13-
| other.ts:3:1:3:15 | new Component() | MyComponent |
14-
| other.ts:3:5:3:13 | Component | typeof default in library-tests/TypeScript/EmbeddedInScript/test.vue |
15-
| other.ts:5:17:5:19 | foo | () => void |
14+
| other.ts:2:8:2:19 | ComponentTsx | typeof default in library-tests/TypeScript/EmbeddedInScript/test_tsx.vue |
15+
| other.ts:2:26:2:41 | "./test_tsx.vue" | any |
16+
| other.ts:4:1:4:15 | new Component() | MyComponent |
17+
| other.ts:4:5:4:13 | Component | typeof default in library-tests/TypeScript/EmbeddedInScript/test.vue |
18+
| other.ts:5:1:5:18 | new ComponentTsx() | MyComponentTsx |
19+
| other.ts:5:5:5:16 | ComponentTsx | typeof default in library-tests/TypeScript/EmbeddedInScript/test_tsx.vue |
20+
| other.ts:7:17:7:19 | foo | () => void |
1621
| test.vue:2:15:2:19 | other | typeof library-tests/TypeScript/EmbeddedInScript/other.ts |
1722
| test.vue:2:26:2:34 | "./other" | any |
1823
| test.vue:3:24:3:34 | MyComponent | MyComponent |
1924
| test.vue:4:7:4:7 | x | number |
25+
| test_tsx.vue:2:15:2:19 | other | typeof library-tests/TypeScript/EmbeddedInScript/other.ts |
26+
| test_tsx.vue:2:26:2:34 | "./other" | any |
27+
| test_tsx.vue:3:24:3:37 | MyComponentTsx | MyComponentTsx |
28+
| test_tsx.vue:4:7:4:7 | x | number |
2029
symbols
21-
| other.ts:1:1:6:0 | <toplevel> | library-tests/TypeScript/EmbeddedInScript/other.ts |
30+
| other.ts:1:1:8:0 | <toplevel> | library-tests/TypeScript/EmbeddedInScript/other.ts |
2231
| test.vue:2:3:6:0 | <toplevel> | library-tests/TypeScript/EmbeddedInScript/test.vue |
32+
| test_tsx.vue:2:3:6:0 | <toplevel> | library-tests/TypeScript/EmbeddedInScript/test_tsx.vue |
2333
importTarget
24-
| htmlfile.html:4:13:4:42 | import ... other"; | other.ts:1:1:6:0 | <toplevel> |
34+
| htmlfile.html:4:13:4:42 | import ... other"; | other.ts:1:1:8:0 | <toplevel> |
2535
| other.ts:1:1:1:35 | import ... t.vue"; | test.vue:2:3:6:0 | <toplevel> |
26-
| test.vue:2:3:2:35 | import ... other"; | other.ts:1:1:6:0 | <toplevel> |
36+
| other.ts:2:1:2:42 | import ... x.vue"; | test_tsx.vue:2:3:6:0 | <toplevel> |
37+
| test.vue:2:3:2:35 | import ... other"; | other.ts:1:1:8:0 | <toplevel> |
38+
| test_tsx.vue:2:3:2:35 | import ... other"; | other.ts:1:1:8:0 | <toplevel> |
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import Component from "./test.vue";
2+
import ComponentTsx from "./test_tsx.vue";
23

34
new Component();
5+
new ComponentTsx();
46

57
export function foo() {};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<script lang='tsx'>
2+
import * as other from "./other";
3+
export default class MyComponentTsx {
4+
x!: number;
5+
}
6+
</script>

0 commit comments

Comments
 (0)