Skip to content

Commit 79b7146

Browse files
committed
Cleanup of types
1 parent 9c28480 commit 79b7146

File tree

5 files changed

+371
-124
lines changed

5 files changed

+371
-124
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9766,7 +9766,7 @@ namespace ts {
97669766
return type;
97679767
}
97689768

9769-
function checkFunctionExpressionOrObjectLiteralMethodBody(node: FunctionExpression | MethodDeclaration) {
9769+
function checkFunctionExpressionOrObjectLiteralMethodBody(node: ArrowFunction | FunctionExpression | MethodDeclaration) {
97709770
Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node));
97719771

97729772
const isAsync = isAsyncFunctionLike(node);

src/compiler/parser.ts

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ namespace ts {
10821082
token === SyntaxKind.NumericLiteral;
10831083
}
10841084

1085-
function parsePropertyNameWorker(allowComputedPropertyNames: boolean): DeclarationName {
1085+
function parsePropertyNameWorker(allowComputedPropertyNames: boolean): PropertyName {
10861086
if (token === SyntaxKind.StringLiteral || token === SyntaxKind.NumericLiteral) {
10871087
return parseLiteralNode(/*internName*/ true);
10881088
}
@@ -1092,7 +1092,7 @@ namespace ts {
10921092
return parseIdentifierName();
10931093
}
10941094

1095-
function parsePropertyName(): DeclarationName {
1095+
function parsePropertyName(): PropertyName {
10961096
return parsePropertyNameWorker(/*allowComputedPropertyNames:*/ true);
10971097
}
10981098

@@ -1152,7 +1152,7 @@ namespace ts {
11521152
}
11531153

11541154
function parseAnyContextualModifier(): boolean {
1155-
return isModifier(token) && tryParse(nextTokenCanFollowModifier);
1155+
return isModifierKind(token) && tryParse(nextTokenCanFollowModifier);
11561156
}
11571157

11581158
function canFollowModifier(): boolean {
@@ -1999,7 +1999,7 @@ namespace ts {
19991999
}
20002000

20012001
function isStartOfParameter(): boolean {
2002-
return token === SyntaxKind.DotDotDotToken || isIdentifierOrPattern() || isModifier(token) || token === SyntaxKind.AtToken;
2002+
return token === SyntaxKind.DotDotDotToken || isIdentifierOrPattern() || isModifierKind(token) || token === SyntaxKind.AtToken;
20032003
}
20042004

20052005
function setModifiers(node: Node, modifiers: ModifiersArray) {
@@ -2020,7 +2020,7 @@ namespace ts {
20202020

20212021
node.name = parseIdentifierOrPattern();
20222022

2023-
if (getFullWidth(node.name) === 0 && node.flags === 0 && isModifier(token)) {
2023+
if (getFullWidth(node.name) === 0 && node.flags === 0 && isModifierKind(token)) {
20242024
// in cases like
20252025
// 'use strict'
20262026
// function foo(static)
@@ -2127,8 +2127,8 @@ namespace ts {
21272127
parseSemicolon();
21282128
}
21292129

2130-
function parseSignatureMember(kind: SyntaxKind): SignatureDeclaration {
2131-
const node = <SignatureDeclaration>createNode(kind);
2130+
function parseSignatureMember(kind: SyntaxKind): CallSignatureDeclaration | ConstructSignatureDeclaration {
2131+
const node = <CallSignatureDeclaration | ConstructSignatureDeclaration>createNode(kind);
21322132
if (kind === SyntaxKind.ConstructSignature) {
21332133
parseExpected(SyntaxKind.NewKeyword);
21342134
}
@@ -2167,7 +2167,7 @@ namespace ts {
21672167
return true;
21682168
}
21692169

2170-
if (isModifier(token)) {
2170+
if (isModifierKind(token)) {
21712171
nextToken();
21722172
if (isIdentifier()) {
21732173
return true;
@@ -2210,13 +2210,13 @@ namespace ts {
22102210
return finishNode(node);
22112211
}
22122212

2213-
function parsePropertyOrMethodSignature(): Declaration {
2213+
function parsePropertyOrMethodSignature(): PropertySignature | MethodSignature {
22142214
const fullStart = scanner.getStartPos();
22152215
const name = parsePropertyName();
22162216
const questionToken = parseOptionalToken(SyntaxKind.QuestionToken);
22172217

22182218
if (token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) {
2219-
const method = <MethodDeclaration>createNode(SyntaxKind.MethodSignature, fullStart);
2219+
const method = <MethodSignature>createNode(SyntaxKind.MethodSignature, fullStart);
22202220
method.name = name;
22212221
method.questionToken = questionToken;
22222222

@@ -2227,7 +2227,7 @@ namespace ts {
22272227
return finishNode(method);
22282228
}
22292229
else {
2230-
const property = <PropertyDeclaration>createNode(SyntaxKind.PropertySignature, fullStart);
2230+
const property = <PropertySignature>createNode(SyntaxKind.PropertySignature, fullStart);
22312231
property.name = name;
22322232
property.questionToken = questionToken;
22332233
property.type = parseTypeAnnotation();
@@ -2243,7 +2243,7 @@ namespace ts {
22432243
case SyntaxKind.OpenBracketToken: // Both for indexers and computed properties
22442244
return true;
22452245
default:
2246-
if (isModifier(token)) {
2246+
if (isModifierKind(token)) {
22472247
const result = lookAhead(isStartOfIndexSignatureDeclaration);
22482248
if (result) {
22492249
return result;
@@ -2255,7 +2255,7 @@ namespace ts {
22552255
}
22562256

22572257
function isStartOfIndexSignatureDeclaration() {
2258-
while (isModifier(token)) {
2258+
while (isModifierKind(token)) {
22592259
nextToken();
22602260
}
22612261

@@ -2271,7 +2271,7 @@ namespace ts {
22712271
canParseSemicolon();
22722272
}
22732273

2274-
function parseTypeMember(): Declaration {
2274+
function parseTypeMember(): TypeElement {
22752275
switch (token) {
22762276
case SyntaxKind.OpenParenToken:
22772277
case SyntaxKind.LessThanToken:
@@ -2296,7 +2296,7 @@ namespace ts {
22962296
// when incrementally parsing as the parser will produce the Index declaration
22972297
// if it has the same text regardless of whether it is inside a class or an
22982298
// object type.
2299-
if (isModifier(token)) {
2299+
if (isModifierKind(token)) {
23002300
const result = tryParse(parseIndexSignatureWithModifiers);
23012301
if (result) {
23022302
return result;
@@ -2329,14 +2329,14 @@ namespace ts {
23292329
return finishNode(node);
23302330
}
23312331

2332-
function parseObjectTypeMembers(): NodeArray<Declaration> {
2333-
let members: NodeArray<Declaration>;
2332+
function parseObjectTypeMembers(): NodeArray<TypeElement> {
2333+
let members: NodeArray<TypeElement>;
23342334
if (parseExpected(SyntaxKind.OpenBraceToken)) {
23352335
members = parseList(ParsingContext.TypeMembers, parseTypeMember);
23362336
parseExpected(SyntaxKind.CloseBraceToken);
23372337
}
23382338
else {
2339-
members = createMissingList<Declaration>();
2339+
members = createMissingList<TypeElement>();
23402340
}
23412341

23422342
return members;
@@ -2478,11 +2478,11 @@ namespace ts {
24782478
// ( ...
24792479
return true;
24802480
}
2481-
if (isIdentifier() || isModifier(token)) {
2481+
if (isIdentifier() || isModifierKind(token)) {
24822482
nextToken();
24832483
if (token === SyntaxKind.ColonToken || token === SyntaxKind.CommaToken ||
24842484
token === SyntaxKind.QuestionToken || token === SyntaxKind.EqualsToken ||
2485-
isIdentifier() || isModifier(token)) {
2485+
isIdentifier() || isModifierKind(token)) {
24862486
// ( id :
24872487
// ( id ,
24882488
// ( id ?
@@ -2889,7 +2889,7 @@ namespace ts {
28892889
}
28902890

28912891
// This *could* be a parenthesized arrow function.
2892-
// Return Unknown to const the caller know.
2892+
// Return Unknown to let the caller know.
28932893
return Tristate.Unknown;
28942894
}
28952895
else {
@@ -2988,7 +2988,7 @@ namespace ts {
29882988
// user meant to supply a block. For example, if the user wrote:
29892989
//
29902990
// a =>
2991-
// const v = 0;
2991+
// let v = 0;
29922992
// }
29932993
//
29942994
// they may be missing an open brace. Check to see if that's the case so we can
@@ -3215,7 +3215,7 @@ namespace ts {
32153215

32163216
/**
32173217
* Parse ES7 unary expression and await expression
3218-
*
3218+
*
32193219
* ES7 UnaryExpression:
32203220
* 1) SimpleUnaryExpression[?yield]
32213221
* 2) IncrementExpression[?yield] ** UnaryExpression[?yield]
@@ -4716,7 +4716,7 @@ namespace ts {
47164716
return finishNode(node);
47174717
}
47184718

4719-
function parseMethodDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray, asteriskToken: Node, name: DeclarationName, questionToken: Node, diagnosticMessage?: DiagnosticMessage): MethodDeclaration {
4719+
function parseMethodDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray, asteriskToken: Node, name: PropertyName, questionToken: Node, diagnosticMessage?: DiagnosticMessage): MethodDeclaration {
47204720
const method = <MethodDeclaration>createNode(SyntaxKind.MethodDeclaration, fullStart);
47214721
method.decorators = decorators;
47224722
setModifiers(method, modifiers);
@@ -4730,7 +4730,7 @@ namespace ts {
47304730
return finishNode(method);
47314731
}
47324732

4733-
function parsePropertyDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray, name: DeclarationName, questionToken: Node): ClassElement {
4733+
function parsePropertyDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray, name: PropertyName, questionToken: Node): ClassElement {
47344734
const property = <PropertyDeclaration>createNode(SyntaxKind.PropertyDeclaration, fullStart);
47354735
property.decorators = decorators;
47364736
setModifiers(property, modifiers);
@@ -4804,7 +4804,7 @@ namespace ts {
48044804
}
48054805

48064806
// Eat up all modifiers, but hold on to the last one in case it is actually an identifier.
4807-
while (isModifier(token)) {
4807+
while (isModifierKind(token)) {
48084808
idToken = token;
48094809
// If the idToken is a class modifier (protected, private, public, and static), it is
48104810
// certain that we are starting to parse class member. This allows better error recovery
@@ -5014,8 +5014,8 @@ namespace ts {
50145014
// implements is a future reserved word so
50155015
// 'class implements' might mean either
50165016
// - class expression with omitted name, 'implements' starts heritage clause
5017-
// - class with name 'implements'
5018-
// 'isImplementsClause' helps to disambiguate between these two cases
5017+
// - class with name 'implements'
5018+
// 'isImplementsClause' helps to disambiguate between these two cases
50195019
return isIdentifier() && !isImplementsClause()
50205020
? parseIdentifier()
50215021
: undefined;

0 commit comments

Comments
 (0)