mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Co-authored-by: Anders Hejlsberg <andersh@microsoft.com>
This commit is contained in:
co-authored by
Anders Hejlsberg
parent
38a7c0587d
commit
892936f4a1
@@ -14788,8 +14788,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
// these partial properties when identifying discriminant properties, but otherwise they are filtered out
|
||||
// and do not appear to be present in the union type.
|
||||
function getUnionOrIntersectionProperty(type: UnionOrIntersectionType, name: __String, skipObjectFunctionPropertyAugment?: boolean): Symbol | undefined {
|
||||
let property = type.propertyCacheWithoutObjectFunctionPropertyAugment?.get(name) ||
|
||||
!skipObjectFunctionPropertyAugment ? type.propertyCache?.get(name) : undefined;
|
||||
let property = skipObjectFunctionPropertyAugment ?
|
||||
type.propertyCacheWithoutObjectFunctionPropertyAugment?.get(name) :
|
||||
type.propertyCache?.get(name);
|
||||
if (!property) {
|
||||
property = createUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment);
|
||||
if (property) {
|
||||
@@ -14797,7 +14798,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
type.propertyCacheWithoutObjectFunctionPropertyAugment ||= createSymbolTable() :
|
||||
type.propertyCache ||= createSymbolTable();
|
||||
properties.set(name, property);
|
||||
if (skipObjectFunctionPropertyAugment && !type.propertyCache?.get(name)) {
|
||||
// Propagate an entry from the non-augmented cache to the augmented cache unless the property is partial.
|
||||
if (skipObjectFunctionPropertyAugment && !(getCheckFlags(property) & CheckFlags.Partial) && !type.propertyCache?.get(name)) {
|
||||
const properties = type.propertyCache ||= createSymbolTable();
|
||||
properties.set(name, property);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @strict: true
|
||||
// @lib: esnext
|
||||
|
||||
//// interface ComponentOptions<Props> {
|
||||
//// setup?: (props: Props) => void;
|
||||
//// name?: string;
|
||||
//// }
|
||||
////
|
||||
//// interface FunctionalComponent<P> {
|
||||
//// (props: P): void;
|
||||
//// }
|
||||
////
|
||||
//// type ConcreteComponent<Props> =
|
||||
//// | ComponentOptions<Props>
|
||||
//// | FunctionalComponent<Props>;
|
||||
////
|
||||
//// type Component<Props = {}> = ConcreteComponent<Props>;
|
||||
////
|
||||
//// type WithInstallPlugin = { _prefix?: string };
|
||||
////
|
||||
////
|
||||
//// /**/
|
||||
//// export function withInstall<C extends Component, T extends WithInstallPlugin>(
|
||||
//// component: C | C[],
|
||||
//// target?: T,
|
||||
//// ): string {
|
||||
//// const componentWithInstall = (target ?? component) as T;
|
||||
//// const components = Array.isArray(component) ? component : [component];
|
||||
////
|
||||
//// const { name } = components[0];
|
||||
//// if (name) {
|
||||
//// return name;
|
||||
//// }
|
||||
////
|
||||
//// return "";
|
||||
//// }
|
||||
|
||||
verify.noErrors();
|
||||
|
||||
goTo.marker();
|
||||
edit.insert("type C = Component['name']");
|
||||
|
||||
verify.noErrors();
|
||||
Reference in New Issue
Block a user