mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-11 10:00:13 -06:00
Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
This commit is contained in:
parent
17933ee33a
commit
45b1e3c254
@ -541,6 +541,7 @@ import {
|
||||
isExternalModuleIndicator,
|
||||
isExternalModuleNameRelative,
|
||||
isExternalModuleReference,
|
||||
isExternalModuleSymbol,
|
||||
isExternalOrCommonJsModule,
|
||||
isForInOrOfStatement,
|
||||
isForInStatement,
|
||||
@ -8975,7 +8976,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
const parentSymbol = nodeSymbol
|
||||
&& isSymbolAccessible(nodeSymbol, context.enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ false).accessibility === SymbolAccessibility.Accessible
|
||||
&& lookupSymbolChain(nodeSymbol, context, meaning, /*yieldModuleSymbol*/ true)[0];
|
||||
if (parentSymbol && parentSymbol.flags & SymbolFlags.Module) {
|
||||
if (parentSymbol && isExternalModuleSymbol(parentSymbol)) {
|
||||
name = getSpecifierForModuleSymbol(parentSymbol, context);
|
||||
}
|
||||
else {
|
||||
|
||||
@ -632,6 +632,15 @@ export function isTransientSymbol(symbol: Symbol): symbol is TransientSymbol {
|
||||
return (symbol.flags & SymbolFlags.Transient) !== 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* True if the symbol is for an external module, as opposed to a namespace.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function isExternalModuleSymbol(moduleSymbol: Symbol): boolean {
|
||||
return !!(moduleSymbol.flags & SymbolFlags.Module) && (moduleSymbol.escapedName as string).charCodeAt(0) === CharacterCodes.doubleQuote;
|
||||
}
|
||||
|
||||
const stringWriter = createSingleLineStringWriter();
|
||||
|
||||
function createSingleLineStringWriter(): EmitTextWriter {
|
||||
|
||||
@ -2408,15 +2408,6 @@ export function isTypeKeywordTokenOrIdentifier(node: Node) {
|
||||
return isTypeKeywordToken(node) || isIdentifier(node) && node.text === "type";
|
||||
}
|
||||
|
||||
/**
|
||||
* True if the symbol is for an external module, as opposed to a namespace.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function isExternalModuleSymbol(moduleSymbol: Symbol): boolean {
|
||||
return !!(moduleSymbol.flags & SymbolFlags.Module) && moduleSymbol.name.charCodeAt(0) === CharacterCodes.doubleQuote;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` the first time it encounters a node and `false` afterwards.
|
||||
*
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
/types.js(3,21): error TS2304: Cannot find name 'Keyword'.
|
||||
/types.js(3,30): error TS2304: Cannot find name 'ParamValueTyped'.
|
||||
|
||||
|
||||
==== /contractHelper.d.ts (0 errors) ====
|
||||
export function handleParamGovernance(zcf: any): {
|
||||
publicMixin: {
|
||||
getGovernedParams: () => globalThis.ERef<import("./types.js").ParamStateRecord>;
|
||||
};
|
||||
};
|
||||
|
||||
==== /exported.d.ts (0 errors) ====
|
||||
type _ERef<T> = T | Promise<T>;
|
||||
import { ParamStateRecord as _ParamStateRecord } from './types.js';
|
||||
declare global {
|
||||
// @ts-ignore TS2666
|
||||
export {
|
||||
_ERef as ERef,
|
||||
_ParamStateRecord as ParamStateRecord,
|
||||
};
|
||||
}
|
||||
|
||||
==== /types.js (2 errors) ====
|
||||
export {};
|
||||
/**
|
||||
* @typedef {Record<Keyword, ParamValueTyped>} ParamStateRecord a Record containing
|
||||
~~~~~~~
|
||||
!!! error TS2304: Cannot find name 'Keyword'.
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2304: Cannot find name 'ParamValueTyped'.
|
||||
* keyword pairs with descriptions of parameters under governance.
|
||||
*/
|
||||
|
||||
==== /index.js (0 errors) ====
|
||||
import { handleParamGovernance } from './contractHelper.js';
|
||||
export const blah = handleParamGovernance({});
|
||||
|
||||
@ -0,0 +1,46 @@
|
||||
//// [tests/cases/compiler/reuseTypeAnnotationImportTypeInGlobalThisTypeArgument.ts] ////
|
||||
|
||||
//// [contractHelper.d.ts]
|
||||
export function handleParamGovernance(zcf: any): {
|
||||
publicMixin: {
|
||||
getGovernedParams: () => globalThis.ERef<import("./types.js").ParamStateRecord>;
|
||||
};
|
||||
};
|
||||
|
||||
//// [exported.d.ts]
|
||||
type _ERef<T> = T | Promise<T>;
|
||||
import { ParamStateRecord as _ParamStateRecord } from './types.js';
|
||||
declare global {
|
||||
// @ts-ignore TS2666
|
||||
export {
|
||||
_ERef as ERef,
|
||||
_ParamStateRecord as ParamStateRecord,
|
||||
};
|
||||
}
|
||||
|
||||
//// [types.js]
|
||||
export {};
|
||||
/**
|
||||
* @typedef {Record<Keyword, ParamValueTyped>} ParamStateRecord a Record containing
|
||||
* keyword pairs with descriptions of parameters under governance.
|
||||
*/
|
||||
|
||||
//// [index.js]
|
||||
import { handleParamGovernance } from './contractHelper.js';
|
||||
export const blah = handleParamGovernance({});
|
||||
|
||||
|
||||
|
||||
|
||||
//// [types.d.ts]
|
||||
/**
|
||||
* a Record containing
|
||||
* keyword pairs with descriptions of parameters under governance.
|
||||
*/
|
||||
export type ParamStateRecord = Record<Keyword, ParamValueTyped>;
|
||||
//// [index.d.ts]
|
||||
export const blah: {
|
||||
publicMixin: {
|
||||
getGovernedParams: () => globalThis.ERef<import("./types.js").ParamStateRecord>;
|
||||
};
|
||||
};
|
||||
@ -0,0 +1,34 @@
|
||||
// @checkJs: true
|
||||
// @declaration: true
|
||||
// @module: preserve
|
||||
// @emitDeclarationOnly: true
|
||||
// @noTypesAndSymbols: true
|
||||
|
||||
// @Filename: /contractHelper.d.ts
|
||||
export function handleParamGovernance(zcf: any): {
|
||||
publicMixin: {
|
||||
getGovernedParams: () => globalThis.ERef<import("./types.js").ParamStateRecord>;
|
||||
};
|
||||
};
|
||||
|
||||
// @Filename: /exported.d.ts
|
||||
type _ERef<T> = T | Promise<T>;
|
||||
import { ParamStateRecord as _ParamStateRecord } from './types.js';
|
||||
declare global {
|
||||
// @ts-ignore TS2666
|
||||
export {
|
||||
_ERef as ERef,
|
||||
_ParamStateRecord as ParamStateRecord,
|
||||
};
|
||||
}
|
||||
|
||||
// @Filename: /types.js
|
||||
export {};
|
||||
/**
|
||||
* @typedef {Record<Keyword, ParamValueTyped>} ParamStateRecord a Record containing
|
||||
* keyword pairs with descriptions of parameters under governance.
|
||||
*/
|
||||
|
||||
// @Filename: /index.js
|
||||
import { handleParamGovernance } from './contractHelper.js';
|
||||
export const blah = handleParamGovernance({});
|
||||
Loading…
x
Reference in New Issue
Block a user