Skip to content

Commit 21acf4f

Browse files
authored
Merge pull request #24136 from Microsoft/inferFromUsageFixes
Remove assert in `symbolToParameterDeclaration`
2 parents bc79917 + 6f4ed3a commit 21acf4f

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3607,7 +3607,7 @@ namespace ts {
36073607

36083608
function symbolToParameterDeclaration(parameterSymbol: Symbol, context: NodeBuilderContext, preserveModifierFlags?: boolean): ParameterDeclaration {
36093609
const parameterDeclaration = getDeclarationOfKind<ParameterDeclaration>(parameterSymbol, SyntaxKind.Parameter);
3610-
Debug.assert(!!parameterDeclaration || isTransientSymbol(parameterSymbol) && !!parameterSymbol.isRestParameter);
3610+
Debug.assert(!!parameterDeclaration || isTransientSymbol(parameterSymbol));
36113611

36123612
let parameterType = getTypeOfSymbol(parameterSymbol);
36133613
if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) {
@@ -3616,7 +3616,8 @@ namespace ts {
36163616
const parameterTypeNode = typeToTypeNodeHelper(parameterType, context);
36173617

36183618
const modifiers = !(context.flags & NodeBuilderFlags.OmitParameterModifiers) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers && parameterDeclaration.modifiers.map(getSynthesizedClone);
3619-
const dotDotDotToken = !parameterDeclaration || isRestParameter(parameterDeclaration) ? createToken(SyntaxKind.DotDotDotToken) : undefined;
3619+
const isRest = parameterDeclaration ? isRestParameter(parameterDeclaration) : (parameterSymbol as TransientSymbol).isRestParameter;
3620+
const dotDotDotToken = isRest ? createToken(SyntaxKind.DotDotDotToken) : undefined;
36203621
const name = parameterDeclaration
36213622
? parameterDeclaration.name ?
36223623
parameterDeclaration.name.kind === SyntaxKind.Identifier ?
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// @noImplicitAny: true
4+
// @jsx: react
5+
// @module: es2015
6+
// @moduleResolution: node
7+
8+
// @Filename: /node_modules/@types/react/index.d.ts
9+
////export = React;
10+
////export as namespace React;
11+
////declare namespace React {
12+
//// export class Component { render(): JSX.Element | null; }
13+
////}
14+
////declare global {
15+
//// namespace JSX {
16+
//// interface Element {}
17+
//// }
18+
////}
19+
20+
21+
// @filename: a.tsx
22+
//// import React from 'react';
23+
////
24+
//// export default function Component([|props |]) {
25+
//// if (props.isLoading) {
26+
//// return <div>...Loading < /div>;
27+
//// }
28+
//// else {
29+
//// return <AnotherComponent
30+
//// update={
31+
//// (rec) => {
32+
//// return props.update(rec);
33+
//// }
34+
//// }
35+
//// />;
36+
//// }
37+
//// }
38+
39+
40+
verify.rangeAfterCodeFix("props: { isLoading: any; update: (arg0: any) => void; }",/*includeWhiteSpace*/ undefined, /*errorCode*/ undefined, 0);

0 commit comments

Comments
 (0)