Skip to content

Commit

Permalink
Showing 2 changed files with 24 additions and 6 deletions.
14 changes: 14 additions & 0 deletions packages/knip/fixtures/imports/index.ts
Original file line number Diff line number Diff line change
@@ -57,6 +57,20 @@ function promiseAll() {
};
}

function promiseTail() {
return {
async fn() {
const [, , identifierB] = await Promise.all([
import('./dir/import-b'),
import('./dir/import-b'),
import('./dir/import-b'),
]);

[identifierB];
},
};
}

(await import('./prop-access')).propAccess;

const {
Original file line number Diff line number Diff line change
@@ -143,12 +143,16 @@ export default visit(
});
}

// Pattern: const [a, b] = await Promise.all([import('A'), import('B')]);
// @ts-expect-error TODO FIXME Property 'name' does not exist on type 'OmittedExpression'.
const alias = element.name.escapedText;
// @ts-expect-error TODO FIXME Property 'symbol' does not exist on type 'BindingElement'.
const symbol = isTLA ? element.symbol : undefined;
return { identifier: 'default', symbol, alias, specifier, pos: element.pos };
if (!ts.isOmittedExpression(element) && ts.isIdentifier(element.name)) {
// Pattern: const [a, b] = await Promise.all([import('A'), import('B')]);
// @ts-expect-error TODO FIXME Property 'name' does not exist on type 'OmittedExpression'.
const alias = element.name.escapedText;
// @ts-expect-error TODO FIXME Property 'symbol' does not exist on type 'BindingElement'.
const symbol = isTLA ? element.symbol : undefined;
return { identifier: 'default', symbol, alias, specifier, pos: element.pos };
}

return { identifier: 'default', specifier, pos: element.pos };
}
}

0 comments on commit 858c0b7

Please sign in to comment.