mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 12:32:08 -06:00
fix type import check for default-import/re-export in js files (#57778)
This commit is contained in:
parent
f3f70df94e
commit
b0d5ae6091
@ -2706,7 +2706,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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
59
tests/cases/fourslash/jsFileImportNoTypes2.ts
Normal file
59
tests/cases/fourslash/jsFileImportNoTypes2.ts
Normal file
@ -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,
|
||||
}
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user