mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 21:36:50 -05:00
Address PR:fix find-all-refs and slim down code
Also add readonly to find-all-ref test
This commit is contained in:
@@ -5495,7 +5495,7 @@ namespace ts {
|
||||
prop.checkFlags = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp) ? CheckFlags.Readonly : 0;
|
||||
prop.type = propType;
|
||||
if (propertySymbol) {
|
||||
prop.mappedTypeOrigin = propertySymbol;
|
||||
prop.syntheticOrigin = propertySymbol;
|
||||
}
|
||||
members.set(propName, prop);
|
||||
}
|
||||
@@ -7449,7 +7449,6 @@ namespace ts {
|
||||
const declarations: Declaration[] = concatenate(leftProp.declarations, rightProp.declarations);
|
||||
const flags = SymbolFlags.Property | (leftProp.flags & SymbolFlags.Optional);
|
||||
const result = createSymbol(flags, leftProp.name);
|
||||
result.checkFlags = 0;
|
||||
result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, TypeFacts.NEUndefined)]);
|
||||
result.leftSpread = leftProp;
|
||||
result.rightSpread = rightProp;
|
||||
@@ -7465,15 +7464,14 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getNonReadonlySymbol(prop: Symbol) {
|
||||
if (!(getDeclarationModifierFlagsFromSymbol(prop) & ModifierFlags.Readonly)) {
|
||||
if (!isReadonlySymbol(prop)) {
|
||||
return prop;
|
||||
}
|
||||
const declarations: Declaration[] = prop.declarations;
|
||||
const flags = SymbolFlags.Property | (prop.flags & SymbolFlags.Optional);
|
||||
const result = createSymbol(flags, prop.name);
|
||||
result.checkFlags = 0;
|
||||
result.type = getTypeOfSymbol(prop);
|
||||
result.declarations = declarations;
|
||||
result.declarations = prop.declarations;
|
||||
result.syntheticOrigin = prop;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -22140,10 +22138,10 @@ namespace ts {
|
||||
else if (symbol.flags & SymbolFlags.Transient) {
|
||||
if ((symbol as SymbolLinks).leftSpread) {
|
||||
const links = symbol as SymbolLinks;
|
||||
return [links.leftSpread, links.rightSpread];
|
||||
return [...getRootSymbols(links.leftSpread), ...getRootSymbols(links.rightSpread)];
|
||||
}
|
||||
if ((symbol as SymbolLinks).mappedTypeOrigin) {
|
||||
return getRootSymbols((symbol as SymbolLinks).mappedTypeOrigin);
|
||||
if ((symbol as SymbolLinks).syntheticOrigin) {
|
||||
return getRootSymbols((symbol as SymbolLinks).syntheticOrigin);
|
||||
}
|
||||
|
||||
let target: Symbol;
|
||||
|
||||
@@ -2852,7 +2852,7 @@ namespace ts {
|
||||
containingType?: UnionOrIntersectionType; // Containing union or intersection type for synthetic property
|
||||
leftSpread?: Symbol; // Left source for synthetic spread property
|
||||
rightSpread?: Symbol; // Right source for synthetic spread property
|
||||
mappedTypeOrigin?: Symbol; // For a property on a mapped type, points back to the orignal 'T' from 'keyof T'.
|
||||
syntheticOrigin?: Symbol; // For a property on a mapped or spread type, points back to the original property
|
||||
isDiscriminantProperty?: boolean; // True if discriminant synthetic property
|
||||
resolvedExports?: SymbolTable; // Resolved exports of module
|
||||
exportsChecked?: boolean; // True if exports of external module have been checked
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface A1 { [|{| "isWriteAccess": true, "isDefinition": true |}a|]: string };
|
||||
////interface A1 { readonly [|{| "isWriteAccess": true, "isDefinition": true |}a|]: string };
|
||||
////interface A2 { [|{| "isWriteAccess": true, "isDefinition": true |}a|]?: number };
|
||||
////let a1: A1;
|
||||
////let a2: A2;
|
||||
////let a12 = { ...a1, ...a2 };
|
||||
////a12.[|a|];
|
||||
////a1.[|a|];
|
||||
const ranges = test.ranges();
|
||||
const [r0, r1, r2] = ranges;
|
||||
const [r0, r1, r2, r3] = ranges;
|
||||
|
||||
// members of spread types only refer to themselves and the resulting property
|
||||
verify.referenceGroups(r0, [{ definition: "(property) A1.a: string", ranges: [r0, r2] }]);
|
||||
verify.referenceGroups(r0, [{ definition: "(property) A1.a: string", ranges: [r0, r2, r3] }]);
|
||||
verify.referenceGroups(r1, [{ definition: "(property) A2.a: number", ranges: [r1, r2] }]);
|
||||
|
||||
// but the resulting property refers to everything
|
||||
verify.referenceGroups(r2, [
|
||||
{ definition: "(property) A1.a: string", ranges: [r0] },
|
||||
{ definition: "(property) A1.a: string", ranges: [r0, r3] },
|
||||
{ definition: "(property) A2.a: number", ranges: [r1] },
|
||||
{ definition: "(property) a: string | number", ranges: [r2] }
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user