File tree Expand file tree Collapse file tree 4 files changed +19
-1
lines changed
ql/test/library-tests/TypeScript/EmbeddedInScript Expand file tree Collapse file tree 4 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 1
1
package com .semmle .js .extractor ;
2
2
3
+ import java .util .regex .Pattern ;
4
+
3
5
import com .semmle .js .extractor .ExtractorConfig .Platform ;
4
6
import com .semmle .js .extractor .ExtractorConfig .SourceType ;
5
7
import com .semmle .js .parser .ParseError ;
6
8
import com .semmle .util .data .StringUtil ;
7
9
import com .semmle .util .trap .TrapWriter ;
8
10
import com .semmle .util .trap .TrapWriter .Label ;
9
- import java . util . regex . Pattern ;
11
+
10
12
import net .htmlparser .jericho .Attribute ;
11
13
import net .htmlparser .jericho .Attributes ;
12
14
import net .htmlparser .jericho .CharacterReference ;
@@ -143,6 +145,10 @@ private SourceType getScriptSourceType(Element script) {
143
145
String scriptType = getAttributeValueLC (script , "type" );
144
146
String scriptLanguage = getAttributeValueLC (script , "language" );
145
147
148
+ if (scriptLanguage == null ) { // Vue templates use 'lang' instead of 'language'.
149
+ scriptLanguage = getAttributeValueLC (script , "lang" );
150
+ }
151
+
146
152
// if `type` and `language` are both either missing, contain the
147
153
// string "javascript", or if `type` is the string "text/jsx", this is a plain script
148
154
if ((scriptType == null || scriptType .contains ("javascript" ) || "text/jsx" .equals (scriptType ))
Original file line number Diff line number Diff line change
1
+ classDeclaration
2
+ exprType
Original file line number Diff line number Diff line change
1
+ import javascript
2
+
3
+ query ClassDefinition classDeclaration ( ) { any ( ) }
4
+
5
+ query Type exprType ( Expr e ) { result = e .getType ( ) }
Original file line number Diff line number Diff line change
1
+ <script lang='ts'>
2
+ export default class MyComponent {
3
+ x! : number ;
4
+ }
5
+ </script >
You can’t perform that action at this time.
0 commit comments