Conversation
There was a problem hiding this comment.
Pull request overview
This PR deprecates the use of assert in TypeScript import type expressions, requiring developers to use the newer with keyword instead. This aligns with the broader JavaScript/TypeScript evolution toward import attributes.
Changes:
- Updated test cases to use
withinstead ofassertin import type expressions - Added deprecation diagnostic for
assertusage in import types - Created new test files to verify deprecation warnings and ignore behavior
Reviewed changes
Copilot reviewed 47 out of 47 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/cases/conformance/node/nodeModulesImportTypeModeDeclarationEmitErrors1.ts | Updated import type syntax from assert to with |
| tests/cases/conformance/node/nodeModulesImportTypeModeDeclarationEmit1.ts | Updated import type syntax from assert to with |
| tests/cases/conformance/moduleResolution/resolutionModeImportType1.ts | Updated import type syntax from assert to with |
| tests/cases/compiler/parseAssertEntriesError.ts | Updated import type syntax from assert to with |
| tests/cases/compiler/importTypeAssertionDeprecationIgnored.ts | New test file verifying ignoreDeprecations: "6.0" suppresses the warning |
| tests/cases/compiler/importTypeAssertionDeprecation.ts | New test file demonstrating the deprecation warning for assert usage |
| tests/baselines/reference/*.types | Updated baseline files reflecting the syntax changes |
| tests/baselines/reference/*.symbols | Updated baseline files reflecting the syntax changes |
| tests/baselines/reference/*.errors.txt | Updated baseline files showing new deprecation errors for assert usage |
| tests/baselines/reference/*.js | Updated baseline files with emitted JavaScript output |
| src/compiler/checker.ts | Added deprecation check for assert keyword in import type expressions |
Comments suppressed due to low confidence (1)
tests/cases/compiler/importTypeAssertionDeprecation.ts:1
- The comment on line 10 states 'Should be deprecated - uses 'assert' instead of 'with'', but the actual test file content shows line 11 also uses 'assert', while the comment on line 14 says 'Should be fine - uses 'with''. However, the baseline errors show both lines trigger deprecation errors. The test case comments are inconsistent with the actual test content - line 11 should use
withif it's supposed to be 'fine'.
|
We don't have a test with |
|
|
||
| // @Filename: /main.ts | ||
| type A = import("./types", { assert: { "resolution-mode": "import" } }).MyType; | ||
| type B = import("./types", { assert: { "resolution-mode": "require" } }).MyType; |
There was a problem hiding this comment.
These are both for qualified names - are import() type nodes also what we use in typeof import(...) and typeof import(...).someValue? If so, can we add tests for that too?
There was a problem hiding this comment.
Yeah, that's another construct I missed.
|
I assume we have tests for runtime |
This was missed in #63077.
Perhaps slightly more dubious, given this isn't syntax per se, but interpreted at runtime?