ts-morph
ts-morph copied to clipboard
Property `getAssertClause` does not exist on type `ImportDeclaration`
Describe the bug
Version: 21.0.1
To Reproduce
When upgrading from ts-morph v20 to v21 the getAssertClause is no longer available on an ImportDeclaration:
import {Project, SyntaxKind} from 'ts-morph';
const project = new Project();
project.getSourceFiles().forEach(sourceFile => {
sourceFile.getImportDeclarations().forEach(importDeclaration => {
importDeclaration.getDescendantsOfKind(SyntaxKind.StringLiteral).forEach(() => {
// It fails here:
console.log(importDeclaration.getAssertClause());
});
});
});
Expected behavior
I wish to call this method but I couldn't find any hint in the release notes where to find it now: https://github.com/dsherret/ts-morph/releases
@dsherret can you give me a hint what I can use instead of getAssertClause()?
Edit: Telling from this change I have to call getAttributes() now? I guess this is because TS 5.3 updated to the import attributes proposal (source).
Ok, I am using getAttributes() now but it would be nice to know how to find assert clauses in legacy code. I would need it to write a codemod that can convert the old assert {type: 'json'} syntax into with {type: 'json'}.