Skip to content

Commit 7b92ae5

Browse files
committed
call nodes too, this is sus
1 parent 107ee58 commit 7b92ae5

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

src/compiler/checker.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37952,6 +37952,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3795237952
if (importCallOptionsType !== emptyObjectType) {
3795337953
checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType, TypeFlags.Undefined), node.arguments[1]);
3795437954
}
37955+
if (compilerOptions.ignoreDeprecations !== "6.0" && isObjectLiteralExpression(node.arguments[1])) {
37956+
for (const prop of node.arguments[1].properties) {
37957+
if (isPropertyAssignment(prop) && isIdentifier(prop.name) && prop.name.escapedText === "assert") {
37958+
grammarErrorOnNode(prop.name, Diagnostics.Import_assertions_have_been_replaced_by_import_attributes_Use_with_instead_of_assert);
37959+
break;
37960+
}
37961+
}
37962+
}
3795537963
}
3795637964

3795737965
// resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
/main.ts(1,38): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
22
/main.ts(2,38): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
3+
/main.ts(4,31): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
4+
/main.ts(5,31): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
35

46

57
==== /types.d.ts (0 errors) ====
68
export interface MyType { x: string }
79

8-
==== /main.ts (2 errors) ====
10+
==== /main.ts (4 errors) ====
911
type A = import("./types", { assert: { "resolution-mode": "import" } }).MyType;
1012
~
1113
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
1214
type B = import("./types", { assert: { "resolution-mode": "require" } }).MyType;
1315
~
1416
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
17+
18+
const a = import("./types", { assert: { "resolution-mode": "import" } });
19+
~~~~~~
20+
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
21+
const b = import("./types", { assert: { "resolution-mode": "require" } });
22+
~~~~~~
23+
!!! error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
1524

tests/cases/compiler/importTypeAssertionDeprecation.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ export interface MyType { x: string }
99
// @Filename: /main.ts
1010
type A = import("./types", { assert: { "resolution-mode": "import" } }).MyType;
1111
type B = import("./types", { assert: { "resolution-mode": "require" } }).MyType;
12+
13+
const a = import("./types", { assert: { "resolution-mode": "import" } });
14+
const b = import("./types", { assert: { "resolution-mode": "require" } });

tests/cases/compiler/importTypeAssertionDeprecationIgnored.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ export interface MyType { x: string }
1111
// With ignoreDeprecations: "6.0", import type assertions should not produce a deprecation error.
1212
type A = import("./types", { assert: { "resolution-mode": "import" } }).MyType;
1313
type B = import("./types", { assert: { "resolution-mode": "require" } }).MyType;
14+
15+
const a = import("./types", { assert: { "resolution-mode": "import" } });
16+
const b = import("./types", { assert: { "resolution-mode": "require" } });

0 commit comments

Comments
 (0)