Skip to content

Commit 47bd4d3

Browse files
authored
Merge pull request #15531 from Microsoft/moreFactoryFuncs
More factory functions
2 parents abb2b82 + 981956a commit 47bd4d3

File tree

7 files changed

+588
-511
lines changed

7 files changed

+588
-511
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2390,7 +2390,7 @@ namespace ts {
23902390
const formattedUnionTypes = formatUnionTypes((<UnionType>type).types);
23912391
const unionTypeNodes = formattedUnionTypes && mapToTypeNodeArray(formattedUnionTypes);
23922392
if (unionTypeNodes && unionTypeNodes.length > 0) {
2393-
return createUnionOrIntersectionTypeNode(SyntaxKind.UnionType, unionTypeNodes);
2393+
return createUnionTypeNode(unionTypeNodes);
23942394
}
23952395
else {
23962396
if (!context.encounteredError && !(context.flags & NodeBuilderFlags.allowEmptyUnionOrIntersection)) {
@@ -2401,7 +2401,7 @@ namespace ts {
24012401
}
24022402

24032403
if (type.flags & TypeFlags.Intersection) {
2404-
return createUnionOrIntersectionTypeNode(SyntaxKind.IntersectionType, mapToTypeNodeArray((type as UnionType).types));
2404+
return createIntersectionTypeNode(mapToTypeNodeArray((type as IntersectionType).types));
24052405
}
24062406

24072407
if (objectFlags & (ObjectFlags.Anonymous | ObjectFlags.Mapped)) {
@@ -2661,7 +2661,7 @@ namespace ts {
26612661
indexerTypeNode,
26622662
/*initializer*/ undefined);
26632663
const typeNode = typeToTypeNodeHelper(indexInfo.type);
2664-
return createIndexSignatureDeclaration(
2664+
return createIndexSignature(
26652665
/*decorators*/ undefined,
26662666
indexInfo.isReadonly ? [createToken(SyntaxKind.ReadonlyKeyword)] : undefined,
26672667
[indexingParameter],

src/compiler/factory.ts

Lines changed: 414 additions & 379 deletions
Large diffs are not rendered by default.

src/compiler/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1506,7 +1506,7 @@ namespace ts {
15061506
// for the same reasons we treat NewExpression as a PrimaryExpression.
15071507
export interface MetaProperty extends PrimaryExpression {
15081508
kind: SyntaxKind.MetaProperty;
1509-
keywordToken: SyntaxKind;
1509+
keywordToken: SyntaxKind.NewKeyword;
15101510
name: Identifier;
15111511
}
15121512

src/compiler/utilities.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3650,7 +3650,18 @@ namespace ts {
36503650
|| kind === SyntaxKind.GetAccessor
36513651
|| kind === SyntaxKind.SetAccessor
36523652
|| kind === SyntaxKind.IndexSignature
3653-
|| kind === SyntaxKind.SemicolonClassElement;
3653+
|| kind === SyntaxKind.SemicolonClassElement
3654+
|| kind === SyntaxKind.MissingDeclaration;
3655+
}
3656+
3657+
export function isTypeElement(node: Node): node is TypeElement {
3658+
const kind = node.kind;
3659+
return kind === SyntaxKind.ConstructSignature
3660+
|| kind === SyntaxKind.CallSignature
3661+
|| kind === SyntaxKind.PropertySignature
3662+
|| kind === SyntaxKind.MethodSignature
3663+
|| kind === SyntaxKind.IndexSignature
3664+
|| kind === SyntaxKind.MissingDeclaration;
36543665
}
36553666

36563667
export function isObjectLiteralElementLike(node: Node): node is ObjectLiteralElementLike {

src/compiler/visitor.ts

Lines changed: 149 additions & 118 deletions
Large diffs are not rendered by default.

src/services/codefixes/fixAddMissingMember.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,16 @@ namespace ts.codefix {
110110
if (!isStatic) {
111111
const stringTypeNode = createKeywordTypeNode(SyntaxKind.StringKeyword);
112112
const indexingParameter = createParameter(
113-
/*decorators*/ undefined,
114-
/*modifiers*/ undefined,
115-
/*dotDotDotToken*/ undefined,
113+
/*decorators*/ undefined,
114+
/*modifiers*/ undefined,
115+
/*dotDotDotToken*/ undefined,
116116
"x",
117-
/*questionToken*/ undefined,
117+
/*questionToken*/ undefined,
118118
stringTypeNode,
119-
/*initializer*/ undefined);
120-
const indexSignature = createIndexSignatureDeclaration(
121-
/*decorators*/ undefined,
122-
/*modifiers*/ undefined,
119+
/*initializer*/ undefined);
120+
const indexSignature = createIndexSignature(
121+
/*decorators*/ undefined,
122+
/*modifiers*/ undefined,
123123
[indexingParameter],
124124
typeNode);
125125

src/services/codefixes/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ namespace ts.codefix {
200200
}
201201

202202
export function createStubbedMethod(modifiers: Modifier[], name: PropertyName, optional: boolean, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], returnType: TypeNode | undefined) {
203-
return createMethodDeclaration(
203+
return createMethod(
204204
/*decorators*/ undefined,
205205
modifiers,
206206
/*asteriskToken*/ undefined,

0 commit comments

Comments
 (0)