Skip to content

Commit a9a21aa

Browse files
committed
Rename DynamicImportExpr::getImport{Attributes => Options}
1 parent 1f4fcf1 commit a9a21aa

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

javascript/ql/lib/semmle/javascript/Expr.qll

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2828,7 +2828,18 @@ class DynamicImportExpr extends @dynamic_import, Expr, Import {
28282828
* import('foo', { with: { type: "json" }})
28292829
* ```
28302830
*/
2831-
Expr getImportAttributes() { result = this.getChildExpr(1) }
2831+
Expr getImportOptions() { result = this.getChildExpr(1) }
2832+
2833+
/**
2834+
* DEPRECATED: use `getImportOptions` instead.
2835+
* Gets the second "argument" to the import expression, that is, the `Y` in `import(X, Y)`.
2836+
*
2837+
* For example, gets the `{ with: { type: "json" }}` expression in the following:
2838+
* ```js
2839+
* import('foo', { with: { type: "json" }})
2840+
* ```
2841+
*/
2842+
deprecated Expr getImportAttributes() { result = this.getImportOptions() }
28322843

28332844
override Module getEnclosingModule() { result = this.getTopLevel() }
28342845

javascript/ql/test/library-tests/TypeScript/ImportAssertions/test.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ getImportAttributesFromExport
2121
| ts-import-assertions.ts:8:1:8:52 | export ... son" }; | ts-import-assertions.ts:8:36:8:51 | { type: "json" } |
2222
| ts-import-assertions.ts:9:1:9:47 | export ... son" }; | ts-import-assertions.ts:9:31:9:46 | { type: "json" } |
2323
| ts-import-assertions.ts:10:1:10:53 | export ... son" }; | ts-import-assertions.ts:10:37:10:52 | { type: "json" } |
24-
getImportAttributes
24+
getImportOptions
2525
| js-import-assertions.js:10:12:10:55 | import( ... n" } }) | js-import-assertions.js:10:29:10:54 | { with: ... on" } } |
2626
| js-import-assertions.js:24:12:24:57 | import( ... n" } }) | js-import-assertions.js:24:29:24:56 | { asser ... on" } } |
2727
| ts-import-assertions.ts:12:12:12:57 | import( ... n" } }) | ts-import-assertions.ts:12:29:12:56 | { asser ... on" } } |

javascript/ql/test/library-tests/TypeScript/ImportAssertions/test.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ query Expr getImportAttributesFromExport(ExportDeclaration decl) {
88
result = decl.getImportAttributes()
99
}
1010

11-
query Expr getImportAttributes(DynamicImportExpr imprt) { result = imprt.getImportAttributes() }
11+
query Expr getImportOptions(DynamicImportExpr imprt) { result = imprt.getImportOptions() }
1212

1313
query JSParseError errors() { any() }

0 commit comments

Comments
 (0)