Skip to content

Commit

Permalink
🤖 Pick PR #57778 (fix type import check for default-i...) into releas…
Browse files Browse the repository at this point in the history
…e-5.4 (#58116)

Co-authored-by: Lyu, Wei-Da <36730922+jasonlyu123@users.noreply.github.com>
  • Loading branch information
TypeScript Bot and jasonlyu123 authored Apr 8, 2024
1 parent 8eb3367 commit b754fc3
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/services/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2674,7 +2674,8 @@ export function getCompletionEntriesFromSymbols(
}

function symbolAppearsToBeTypeOnly(symbol: Symbol): boolean {
return !(symbol.flags & SymbolFlags.Value) && (!isInJSFile(symbol.declarations?.[0]) || !!(symbol.flags & SymbolFlags.Type));
const flags = getCombinedLocalAndExportSymbolFlags(skipAlias(symbol, typeChecker));
return !(flags & SymbolFlags.Value) && (!isInJSFile(symbol.declarations?.[0]) || !!(flags & SymbolFlags.Type));
}
}

Expand Down
59 changes: 59 additions & 0 deletions tests/cases/fourslash/jsFileImportNoTypes2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/// <reference path="fourslash.ts" />

// @allowJs: true

// @Filename: /default.ts
//// export default class TestDefaultClass {}

// @Filename: /defaultType.ts
//// export default interface TestDefaultInterface {}

// @Filename: /reExport/toReExport.ts
//// export class TestClassReExport {}
//// export interface TestInterfaceReExport {}

// @Filename: /reExport/index.ts
//// export { TestClassReExport, TestInterfaceReExport } from './toReExport';

// @Filename: /exportList.ts
//// class TestClassExportList {};
//// interface TestInterfaceExportList {};
//// export { TestClassExportList, TestInterfaceExportList };

// @Filename: /baseline.ts
//// export class TestClassBaseline {}
//// export interface TestInterfaceBaseline {}

// @Filename: /a.js
//// import /**/

verify.completions({
marker: "",
isNewIdentifierLocation: true,
exact: [
{
name: "TestClassBaseline",
insertText: "import { TestClassBaseline } from \"./baseline\";",
source: "./baseline",
},
{
name: "TestClassExportList",
insertText: "import { TestClassExportList } from \"./exportList\";",
source: "./exportList",
},
{
name: "TestClassReExport",
insertText: "import { TestClassReExport } from \"./reExport\";",
source: "./reExport",
},
{
name: "TestDefaultClass",
insertText: "import TestDefaultClass from \"./default\";",
source: "./default",
},
],
preferences: {
includeCompletionsForImportStatements: true,
includeCompletionsWithInsertText: true,
}
});

0 comments on commit b754fc3

Please sign in to comment.