Fix visibility lookup for cjs require aliases
This commit is contained in:
parent
90e944daba
commit
ef810f5d02
|
@ -4164,6 +4164,14 @@ namespace ts {
|
|||
&& isDeclarationVisible(declaration.parent)) {
|
||||
return addVisibleAlias(declaration, declaration);
|
||||
}
|
||||
else if (isBindingElement(declaration) && isInJSFile(declaration) && declaration.parent?.parent // exported import-like top-level JS require statement
|
||||
&& isVariableDeclaration(declaration.parent.parent)
|
||||
&& declaration.parent.parent.parent?.parent && isVariableStatement(declaration.parent.parent.parent.parent)
|
||||
&& !hasSyntacticModifier(declaration.parent.parent.parent.parent, ModifierFlags.Export)
|
||||
&& declaration.parent.parent.parent.parent.parent // check if the thing containing the variable statement is visible (ie, the file)
|
||||
&& isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) {
|
||||
return addVisibleAlias(declaration, declaration.parent.parent.parent.parent);
|
||||
}
|
||||
|
||||
// Declaration is not visible
|
||||
return false;
|
||||
|
|
|
@ -94,14 +94,6 @@ export const testFnTypes: {
|
|||
[x: string]: any;
|
||||
};
|
||||
export namespace testFnTypes {
|
||||
type input = boolean | Function | {
|
||||
/**
|
||||
* - Prop 1.
|
||||
*/
|
||||
prop1: string | RegExp | (string | RegExp)[];
|
||||
/**
|
||||
* - Prop 2.
|
||||
*/
|
||||
prop2: string;
|
||||
};
|
||||
type input = boolean | Function | myTypes.typeB;
|
||||
}
|
||||
import { myTypes } from "./file.js";
|
||||
|
|
|
@ -27,12 +27,12 @@ const testFnTypes = {
|
|||
*/
|
||||
function testFn(input) {
|
||||
>testFn : (input: testFnTypes.input) => number | null
|
||||
>input : boolean | Function | { prop1: string | RegExp | (string | RegExp)[]; prop2: string; }
|
||||
>input : boolean | Function | myTypes.typeB
|
||||
|
||||
if (typeof input === 'number') {
|
||||
>typeof input === 'number' : boolean
|
||||
>typeof input : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
|
||||
>input : boolean | Function | { prop1: string | RegExp | (string | RegExp)[]; prop2: string; }
|
||||
>input : boolean | Function | myTypes.typeB
|
||||
>'number' : "number"
|
||||
|
||||
return 2 * input;
|
||||
|
|
Loading…
Reference in a new issue