Skip to content

Commit 9aa2468

Browse files
committed
Resolve merge issue with upstream
2 parents f82d295 + 84f5aa5 commit 9aa2468

File tree

132 files changed

+3081
-1158
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+3081
-1158
lines changed

src/compiler/checker.ts

+246-88
Large diffs are not rendered by default.

src/compiler/core.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ namespace ts {
531531
return result;
532532
}
533533

534-
export function flatMapIterator<T, U>(iter: Iterator<T>, mapfn: (x: T) => U[] | Iterator<U> | undefined): Iterator<U> {
534+
export function flatMapIterator<T, U>(iter: Iterator<T>, mapfn: (x: T) => ReadonlyArray<U> | Iterator<U> | undefined): Iterator<U> {
535535
const first = iter.next();
536536
if (first.done) {
537537
return emptyIterator;
@@ -1418,7 +1418,9 @@ namespace ts {
14181418
return typeof text === "string";
14191419
}
14201420

1421-
export function tryCast<TOut extends TIn, TIn = any>(value: TIn | undefined, test: (value: TIn) => value is TOut): TOut | undefined {
1421+
export function tryCast<TOut extends TIn, TIn = any>(value: TIn | undefined, test: (value: TIn) => value is TOut): TOut | undefined;
1422+
export function tryCast<T>(value: T, test: (value: T) => boolean): T | undefined;
1423+
export function tryCast<T>(value: T, test: (value: T) => boolean): T | undefined {
14221424
return value !== undefined && test(value) ? value : undefined;
14231425
}
14241426

src/compiler/diagnosticMessages.json

+21
Original file line numberDiff line numberDiff line change
@@ -1452,6 +1452,10 @@
14521452
"category": "Error",
14531453
"code": 2417
14541454
},
1455+
"Type of computed property's value is '{0}', which is not assignable to type '{1}'.": {
1456+
"category": "Error",
1457+
"code": 2418
1458+
},
14551459
"Class '{0}' incorrectly implements interface '{1}'.": {
14561460
"category": "Error",
14571461
"code": 2420
@@ -2401,6 +2405,10 @@
24012405
"category": "Error",
24022406
"code": 2728
24032407
},
2408+
"Property '{0}' is used before its initialization.": {
2409+
"category": "Error",
2410+
"code": 2729
2411+
},
24042412
"The respective 'set' accessor has the type '{0}'.": {
24052413
"category": "Error",
24062414
"code": 2730
@@ -3754,6 +3762,15 @@
37543762
"code": 6371
37553763
},
37563764

3765+
"The expected type comes from property '{0}' which is declared here on type '{1}'": {
3766+
"category": "Message",
3767+
"code": 6500
3768+
},
3769+
"The expected type comes from this index signature.": {
3770+
"category": "Message",
3771+
"code": 6501
3772+
},
3773+
37573774
"Variable '{0}' implicitly has an '{1}' type.": {
37583775
"category": "Error",
37593776
"code": 7005
@@ -4474,5 +4491,9 @@
44744491
"Add missing enum member '{0}'": {
44754492
"category": "Message",
44764493
"code": 95063
4494+
},
4495+
"Add all missing imports": {
4496+
"category": "Message",
4497+
"code": 95064
44774498
}
44784499
}

src/compiler/factory.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -1170,7 +1170,7 @@ namespace ts {
11701170
return node;
11711171
}
11721172

1173-
/* @deprecated */ export function updateArrowFunction(
1173+
/** @deprecated */ export function updateArrowFunction(
11741174
node: ArrowFunction,
11751175
modifiers: ReadonlyArray<Modifier> | undefined,
11761176
typeParameters: ReadonlyArray<TypeParameterDeclaration> | undefined,
@@ -1319,7 +1319,7 @@ namespace ts {
13191319
return node;
13201320
}
13211321

1322-
/* @deprecated */ export function updateConditional(
1322+
/** @deprecated */ export function updateConditional(
13231323
node: ConditionalExpression,
13241324
condition: Expression,
13251325
whenTrue: Expression,
@@ -4354,19 +4354,17 @@ namespace ts {
43544354
case SyntaxKind.ConditionalExpression:
43554355
node = (<ConditionalExpression>node).condition;
43564356
continue;
4357-
43584357
case SyntaxKind.CallExpression:
43594358
if (stopAtCallExpressions) {
43604359
return node;
43614360
}
43624361
// falls through
4362+
case SyntaxKind.AsExpression:
43634363
case SyntaxKind.ElementAccessExpression:
43644364
case SyntaxKind.PropertyAccessExpression:
4365-
node = (<CallExpression | PropertyAccessExpression | ElementAccessExpression>node).expression;
4366-
continue;
4367-
4365+
case SyntaxKind.NonNullExpression:
43684366
case SyntaxKind.PartiallyEmittedExpression:
4369-
node = (<PartiallyEmittedExpression>node).expression;
4367+
node = (<CallExpression | PropertyAccessExpression | ElementAccessExpression | AsExpression | NonNullExpression | PartiallyEmittedExpression>node).expression;
43704368
continue;
43714369
}
43724370

src/compiler/parser.ts

+13-4
Original file line numberDiff line numberDiff line change
@@ -2090,8 +2090,18 @@ namespace ts {
20902090
return result;
20912091
}
20922092

2093-
function createMissingList<T extends Node>(): NodeArray<T> {
2094-
return createNodeArray<T>([], getNodePos());
2093+
interface MissingList<T extends Node> extends NodeArray<T> {
2094+
isMissingList: true;
2095+
}
2096+
2097+
function createMissingList<T extends Node>(): MissingList<T> {
2098+
const list = createNodeArray<T>([], getNodePos()) as MissingList<T>;
2099+
list.isMissingList = true;
2100+
return list;
2101+
}
2102+
2103+
function isMissingList(arr: NodeArray<Node>): boolean {
2104+
return !!(arr as MissingList<Node>).isMissingList;
20952105
}
20962106

20972107
function parseBracketedList<T extends Node>(kind: ParsingContext, parseElement: () => T, open: SyntaxKind, close: SyntaxKind): NodeArray<T> {
@@ -2260,8 +2270,7 @@ namespace ts {
22602270
case SyntaxKind.FunctionType:
22612271
case SyntaxKind.ConstructorType: {
22622272
const { parameters, type } = node as FunctionOrConstructorTypeNode;
2263-
// parameters.pos === parameters.end only if we used parseMissingList, else should contain at least `()`
2264-
return parameters.pos === parameters.end || typeHasArrowFunctionBlockingParseError(type);
2273+
return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type);
22652274
}
22662275
case SyntaxKind.ParenthesizedType:
22672276
return typeHasArrowFunctionBlockingParseError((node as ParenthesizedTypeNode).type);

src/compiler/types.ts

+6
Original file line numberDiff line numberDiff line change
@@ -2883,6 +2883,7 @@ namespace ts {
28832883
getDeclaredTypeOfSymbol(symbol: Symbol): Type;
28842884
getPropertiesOfType(type: Type): Symbol[];
28852885
getPropertyOfType(type: Type, propertyName: string): Symbol | undefined;
2886+
/* @internal */ getTypeOfPropertyOfType(type: Type, propertyName: string): Type | undefined;
28862887
getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo | undefined;
28872888
getSignaturesOfType(type: Type, kind: SignatureKind): ReadonlyArray<Signature>;
28882889
getIndexTypeOfType(type: Type, kind: IndexKind): Type | undefined;
@@ -3045,6 +3046,11 @@ namespace ts {
30453046
/* @internal */ getTypeCount(): number;
30463047

30473048
/* @internal */ isArrayLikeType(type: Type): boolean;
3049+
/**
3050+
* True if `contextualType` should not be considered for completions because
3051+
* e.g. it specifies `kind: "a"` and obj has `kind: "b"`.
3052+
*/
3053+
/* @internal */ isTypeInvalidDueToUnionDiscriminant(contextualType: Type, obj: ObjectLiteralExpression): boolean;
30483054
/**
30493055
* For a union, will include a property if it's defined in *any* of the member types.
30503056
* So for `{ a } | { b }`, this will include both `a` and `b`.

src/compiler/utilities.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -4312,8 +4312,8 @@ namespace ts {
43124312
return !!forEachAncestorDirectory(directory, d => callback(d) ? true : undefined);
43134313
}
43144314

4315-
export function isUMDExportSymbol(symbol: Symbol | undefined) {
4316-
return symbol && symbol.declarations && symbol.declarations[0] && isNamespaceExportDeclaration(symbol.declarations[0]);
4315+
export function isUMDExportSymbol(symbol: Symbol | undefined): boolean {
4316+
return !!symbol && !!symbol.declarations && !!symbol.declarations[0] && isNamespaceExportDeclaration(symbol.declarations[0]);
43174317
}
43184318

43194319
export function showModuleSpecifier({ moduleSpecifier }: ImportDeclaration): string {
@@ -8106,4 +8106,6 @@ namespace ts {
81068106

81078107
return findBestPatternMatch(patterns, _ => _, candidate);
81088108
}
8109+
8110+
export type Mutable<T extends object> = { -readonly [K in keyof T]: T[K] };
81098111
}

src/compiler/watch.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ namespace ts {
490490

491491
const trace = host.trace && ((s: string) => { host.trace!(s + newLine); });
492492
const watchLogLevel = trace ? compilerOptions.extendedDiagnostics ? WatchLogLevel.Verbose :
493-
compilerOptions.diagnostis ? WatchLogLevel.TriggerOnly : WatchLogLevel.None : WatchLogLevel.None;
493+
compilerOptions.diagnostics ? WatchLogLevel.TriggerOnly : WatchLogLevel.None : WatchLogLevel.None;
494494
const writeLog: (s: string) => void = watchLogLevel !== WatchLogLevel.None ? trace! : noop; // TODO: GH#18217
495495
const { watchFile, watchFilePath, watchDirectory } = getWatchFactory<string>(watchLogLevel, writeLog);
496496

src/harness/fourslash.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2643,7 +2643,7 @@ Actual: ${stringify(fullActual)}`);
26432643
}
26442644
const range = ts.firstOrUndefined(ranges);
26452645

2646-
const codeFixes = this.getCodeFixes(fileName, errorCode, preferences).filter(f => f.fixId === undefined); // TODO: GH#20315 filter out those that use the import fix ID;
2646+
const codeFixes = this.getCodeFixes(fileName, errorCode, preferences).filter(f => f.fixId === ts.codefix.importFixId);
26472647

26482648
if (codeFixes.length === 0) {
26492649
if (expectedTextArray.length !== 0) {

src/services/codeFixProvider.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* @internal */
22
namespace ts {
33
export interface CodeFixRegistration {
4-
errorCodes: number[];
4+
errorCodes: ReadonlyArray<number>;
55
getCodeActions(context: CodeFixContext): CodeFixAction[] | undefined;
6-
fixIds?: string[];
6+
fixIds?: ReadonlyArray<string>;
77
getAllCodeActions?(context: CodeFixAllContext): CombinedCodeActions;
88
}
99

@@ -27,7 +27,7 @@ namespace ts {
2727
const errorCodeToFixes = createMultiMap<CodeFixRegistration>();
2828
const fixIdToRegistration = createMap<CodeFixRegistration>();
2929

30-
type DiagnosticAndArguments = DiagnosticMessage | [DiagnosticMessage, string] | [DiagnosticMessage, string, string];
30+
export type DiagnosticAndArguments = DiagnosticMessage | [DiagnosticMessage, string] | [DiagnosticMessage, string, string];
3131
function diagnosticToString(diag: DiagnosticAndArguments): string {
3232
return isArray(diag)
3333
? formatStringFromArgs(getLocaleSpecificMessage(diag[0]), diag.slice(1) as ReadonlyArray<string>)
@@ -89,7 +89,7 @@ namespace ts {
8989
return createCombinedCodeActions(changes, commands.length === 0 ? undefined : commands);
9090
}
9191

92-
export function eachDiagnostic({ program, sourceFile, cancellationToken }: CodeFixAllContext, errorCodes: number[], cb: (diag: DiagnosticWithLocation) => void): void {
92+
export function eachDiagnostic({ program, sourceFile, cancellationToken }: CodeFixAllContext, errorCodes: ReadonlyArray<number>, cb: (diag: DiagnosticWithLocation) => void): void {
9393
for (const diag of program.getSemanticDiagnostics(sourceFile, cancellationToken).concat(computeSuggestionDiagnostics(sourceFile, program, cancellationToken))) {
9494
if (contains(errorCodes, diag.code)) {
9595
cb(diag as DiagnosticWithLocation);

0 commit comments

Comments
 (0)