Skip to content

Commit d37426d

Browse files
committed
Fill out remaining factory functions
1 parent 88f9a97 commit d37426d

File tree

8 files changed

+606
-510
lines changed

8 files changed

+606
-510
lines changed

src/compiler/checker.ts

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

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

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

src/compiler/factory.ts

Lines changed: 429 additions & 378 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
@@ -3649,7 +3649,18 @@ namespace ts {
36493649
|| kind === SyntaxKind.GetAccessor
36503650
|| kind === SyntaxKind.SetAccessor
36513651
|| kind === SyntaxKind.IndexSignature
3652-
|| kind === SyntaxKind.SemicolonClassElement;
3652+
|| kind === SyntaxKind.SemicolonClassElement
3653+
|| kind === SyntaxKind.MissingDeclaration;
3654+
}
3655+
3656+
export function isTypeElement(node: Node): node is TypeElement {
3657+
const kind = node.kind;
3658+
return kind === SyntaxKind.ConstructSignature
3659+
|| kind === SyntaxKind.CallSignature
3660+
|| kind === SyntaxKind.PropertySignature
3661+
|| kind === SyntaxKind.MethodSignature
3662+
|| kind === SyntaxKind.IndexSignature
3663+
|| kind === SyntaxKind.MissingDeclaration;
36533664
}
36543665

36553666
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/harness/unittests/transform.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ namespace ts {
6868
transformers: {
6969
before: [replaceUndefinedWithVoid0],
7070
after: [replaceIdentifiersNamedOldNameWithNewName]
71+
},
72+
compilerOptions: {
73+
newLine: NewLineKind.LineFeed
7174
}
7275
}).outputText;
7376
});

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)