Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
222 changes: 116 additions & 106 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4427,7 +4427,7 @@

function tryGetQualifiedNameAsValue(node: QualifiedName) {
let left: Identifier | QualifiedName = getFirstIdentifier(node);
let symbol = resolveName(left, left, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*isUse*/ true);

Check failure on line 4430 in src/compiler/checker.ts

View workflow job for this annotation

GitHub Actions / self-check

Argument of type 'Identifier | QualifiedName' is not assignable to parameter of type '__String | Identifier'.
if (!symbol) {
return undefined;
}
Expand Down Expand Up @@ -41533,114 +41533,124 @@
cancellationToken.throwIfCancellationRequested();
}
}
switch (kind) {
case SyntaxKind.Identifier:
return checkIdentifier(node as Identifier, checkMode);
case SyntaxKind.PrivateIdentifier:
return checkPrivateIdentifierExpression(node as PrivateIdentifier);
case SyntaxKind.ThisKeyword:
return checkThisExpression(node);
case SyntaxKind.SuperKeyword:
return checkSuperExpression(node);
case SyntaxKind.NullKeyword:
return nullWideningType;
case SyntaxKind.NoSubstitutionTemplateLiteral:
case SyntaxKind.StringLiteral:
return hasSkipDirectInferenceFlag(node) ?
blockedStringType :
getFreshTypeOfLiteralType(getStringLiteralType((node as StringLiteralLike).text));
case SyntaxKind.NumericLiteral:
checkGrammarNumericLiteral(node as NumericLiteral);
return getFreshTypeOfLiteralType(getNumberLiteralType(+(node as NumericLiteral).text));
case SyntaxKind.BigIntLiteral:
checkGrammarBigIntLiteral(node as BigIntLiteral);
return getFreshTypeOfLiteralType(getBigIntLiteralType({
negative: false,
base10Value: parsePseudoBigInt((node as BigIntLiteral).text),
}));
case SyntaxKind.TrueKeyword:
return trueType;
case SyntaxKind.FalseKeyword:
return falseType;
case SyntaxKind.TemplateExpression:
return checkTemplateExpression(node as TemplateExpression);
case SyntaxKind.RegularExpressionLiteral:
return checkRegularExpressionLiteral(node as RegularExpressionLiteral);
case SyntaxKind.ArrayLiteralExpression:
return checkArrayLiteral(node as ArrayLiteralExpression, checkMode, forceTuple);
case SyntaxKind.ObjectLiteralExpression:
return checkObjectLiteral(node as ObjectLiteralExpression, checkMode);
case SyntaxKind.PropertyAccessExpression:
return checkPropertyAccessExpression(node as PropertyAccessExpression, checkMode);
case SyntaxKind.QualifiedName:
return checkQualifiedName(node as QualifiedName, checkMode);
case SyntaxKind.ElementAccessExpression:
return checkIndexedAccess(node as ElementAccessExpression, checkMode);
case SyntaxKind.CallExpression:
if ((node as CallExpression).expression.kind === SyntaxKind.ImportKeyword) {
return checkImportCallExpression(node as ImportCall);
}
if (node.parent.kind === SyntaxKind.VariableDeclaration && (node.parent as VariableDeclaration).type && !(node.parent.parent.flags & NodeFlags.Const)) {
const src = work();
const target = getTypeFromTypeNode((node.parent as VariableDeclaration).type!);
checkTypeRelatedTo(src, target, assignableRelation, node);
return target;
} else {
return work();
}
function work() {
switch (kind) {
case SyntaxKind.Identifier:
return checkIdentifier(node as Identifier, checkMode);
case SyntaxKind.PrivateIdentifier:
return checkPrivateIdentifierExpression(node as PrivateIdentifier);
case SyntaxKind.ThisKeyword:
return checkThisExpression(node);
case SyntaxKind.SuperKeyword:
return checkSuperExpression(node);
case SyntaxKind.NullKeyword:
return nullWideningType;
case SyntaxKind.NoSubstitutionTemplateLiteral:
case SyntaxKind.StringLiteral:
return hasSkipDirectInferenceFlag(node) ?
blockedStringType :
getFreshTypeOfLiteralType(getStringLiteralType((node as StringLiteralLike).text));
case SyntaxKind.NumericLiteral:
checkGrammarNumericLiteral(node as NumericLiteral);
return getFreshTypeOfLiteralType(getNumberLiteralType(+(node as NumericLiteral).text));
case SyntaxKind.BigIntLiteral:
checkGrammarBigIntLiteral(node as BigIntLiteral);
return getFreshTypeOfLiteralType(getBigIntLiteralType({
negative: false,
base10Value: parsePseudoBigInt((node as BigIntLiteral).text),
}));
case SyntaxKind.TrueKeyword:
return trueType;
case SyntaxKind.FalseKeyword:
return falseType;
case SyntaxKind.TemplateExpression:
return checkTemplateExpression(node as TemplateExpression);
case SyntaxKind.RegularExpressionLiteral:
return checkRegularExpressionLiteral(node as RegularExpressionLiteral);
case SyntaxKind.ArrayLiteralExpression:
return checkArrayLiteral(node as ArrayLiteralExpression, checkMode, forceTuple);
case SyntaxKind.ObjectLiteralExpression:
return checkObjectLiteral(node as ObjectLiteralExpression, checkMode);
case SyntaxKind.PropertyAccessExpression:
return checkPropertyAccessExpression(node as PropertyAccessExpression, checkMode);
case SyntaxKind.QualifiedName:
return checkQualifiedName(node as QualifiedName, checkMode);
case SyntaxKind.ElementAccessExpression:
return checkIndexedAccess(node as ElementAccessExpression, checkMode);
case SyntaxKind.CallExpression:
if ((node as CallExpression).expression.kind === SyntaxKind.ImportKeyword) {
return checkImportCallExpression(node as ImportCall);
}
// falls through
case SyntaxKind.NewExpression:
return checkCallExpression(node as CallExpression, checkMode);
case SyntaxKind.TaggedTemplateExpression:
return checkTaggedTemplateExpression(node as TaggedTemplateExpression);
case SyntaxKind.ParenthesizedExpression:
return checkParenthesizedExpression(node as ParenthesizedExpression, checkMode);
case SyntaxKind.ClassExpression:
return checkClassExpression(node as ClassExpression);
case SyntaxKind.FunctionExpression:
case SyntaxKind.ArrowFunction:
return checkFunctionExpressionOrObjectLiteralMethod(node as FunctionExpression | ArrowFunction, checkMode);
case SyntaxKind.TypeOfExpression:
return checkTypeOfExpression(node as TypeOfExpression);
case SyntaxKind.TypeAssertionExpression:
case SyntaxKind.AsExpression:
return checkAssertion(node as AssertionExpression, checkMode);
case SyntaxKind.NonNullExpression:
return checkNonNullAssertion(node as NonNullExpression);
case SyntaxKind.ExpressionWithTypeArguments:
return checkExpressionWithTypeArguments(node as ExpressionWithTypeArguments);
case SyntaxKind.SatisfiesExpression:
return checkSatisfiesExpression(node as SatisfiesExpression);
case SyntaxKind.MetaProperty:
return checkMetaProperty(node as MetaProperty);
case SyntaxKind.DeleteExpression:
return checkDeleteExpression(node as DeleteExpression);
case SyntaxKind.VoidExpression:
return checkVoidExpression(node as VoidExpression);
case SyntaxKind.AwaitExpression:
return checkAwaitExpression(node as AwaitExpression);
case SyntaxKind.PrefixUnaryExpression:
return checkPrefixUnaryExpression(node as PrefixUnaryExpression);
case SyntaxKind.PostfixUnaryExpression:
return checkPostfixUnaryExpression(node as PostfixUnaryExpression);
case SyntaxKind.BinaryExpression:
return checkBinaryExpression(node as BinaryExpression, checkMode);
case SyntaxKind.ConditionalExpression:
return checkConditionalExpression(node as ConditionalExpression, checkMode);
case SyntaxKind.SpreadElement:
return checkSpreadExpression(node as SpreadElement, checkMode);
case SyntaxKind.OmittedExpression:
return undefinedWideningType;
case SyntaxKind.YieldExpression:
return checkYieldExpression(node as YieldExpression);
case SyntaxKind.SyntheticExpression:
return checkSyntheticExpression(node as SyntheticExpression);
case SyntaxKind.JsxExpression:
return checkJsxExpression(node as JsxExpression, checkMode);
case SyntaxKind.JsxElement:
return checkJsxElement(node as JsxElement, checkMode);
case SyntaxKind.JsxSelfClosingElement:
return checkJsxSelfClosingElement(node as JsxSelfClosingElement, checkMode);
case SyntaxKind.JsxFragment:
return checkJsxFragment(node as JsxFragment);
case SyntaxKind.JsxAttributes:
return checkJsxAttributes(node as JsxAttributes, checkMode);
case SyntaxKind.JsxOpeningElement:
Debug.fail("Shouldn't ever directly check a JsxOpeningElement");
case SyntaxKind.NewExpression:
return checkCallExpression(node as CallExpression, checkMode);
case SyntaxKind.TaggedTemplateExpression:
return checkTaggedTemplateExpression(node as TaggedTemplateExpression);
case SyntaxKind.ParenthesizedExpression:
return checkParenthesizedExpression(node as ParenthesizedExpression, checkMode);
case SyntaxKind.ClassExpression:
return checkClassExpression(node as ClassExpression);
case SyntaxKind.FunctionExpression:
case SyntaxKind.ArrowFunction:
return checkFunctionExpressionOrObjectLiteralMethod(node as FunctionExpression | ArrowFunction, checkMode);
case SyntaxKind.TypeOfExpression:
return checkTypeOfExpression(node as TypeOfExpression);
case SyntaxKind.TypeAssertionExpression:
case SyntaxKind.AsExpression:
return checkAssertion(node as AssertionExpression, checkMode);
case SyntaxKind.NonNullExpression:
return checkNonNullAssertion(node as NonNullExpression);
case SyntaxKind.ExpressionWithTypeArguments:
return checkExpressionWithTypeArguments(node as ExpressionWithTypeArguments);
case SyntaxKind.SatisfiesExpression:
return checkSatisfiesExpression(node as SatisfiesExpression);
case SyntaxKind.MetaProperty:
return checkMetaProperty(node as MetaProperty);
case SyntaxKind.DeleteExpression:
return checkDeleteExpression(node as DeleteExpression);
case SyntaxKind.VoidExpression:
return checkVoidExpression(node as VoidExpression);
case SyntaxKind.AwaitExpression:
return checkAwaitExpression(node as AwaitExpression);
case SyntaxKind.PrefixUnaryExpression:
return checkPrefixUnaryExpression(node as PrefixUnaryExpression);
case SyntaxKind.PostfixUnaryExpression:
return checkPostfixUnaryExpression(node as PostfixUnaryExpression);
case SyntaxKind.BinaryExpression:
return checkBinaryExpression(node as BinaryExpression, checkMode);
case SyntaxKind.ConditionalExpression:
return checkConditionalExpression(node as ConditionalExpression, checkMode);
case SyntaxKind.SpreadElement:
return checkSpreadExpression(node as SpreadElement, checkMode);
case SyntaxKind.OmittedExpression:
return undefinedWideningType;
case SyntaxKind.YieldExpression:
return checkYieldExpression(node as YieldExpression);
case SyntaxKind.SyntheticExpression:
return checkSyntheticExpression(node as SyntheticExpression);
case SyntaxKind.JsxExpression:
return checkJsxExpression(node as JsxExpression, checkMode);
case SyntaxKind.JsxElement:
return checkJsxElement(node as JsxElement, checkMode);
case SyntaxKind.JsxSelfClosingElement:
return checkJsxSelfClosingElement(node as JsxSelfClosingElement, checkMode);
case SyntaxKind.JsxFragment:
return checkJsxFragment(node as JsxFragment);
case SyntaxKind.JsxAttributes:
return checkJsxAttributes(node as JsxAttributes, checkMode);
case SyntaxKind.JsxOpeningElement:
Debug.fail("Shouldn't ever directly check a JsxOpeningElement");
}
return errorType;
}
return errorType;
}

// DECLARATION AND STATEMENT TYPE CHECKING
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ module A {
export var Origin: Point = { x: 0, y: 0 };
>Origin : Point
> : ^^^^^
>{ x: 0, y: 0 } : { x: number; y: number; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
>{ x: 0, y: 0 } : Point
> : ^^^^^
>x : number
> : ^^^^^^
>0 : 0
Expand All @@ -46,8 +46,8 @@ module A {
export var Origin3d: Point3d = { x: 0, y: 0, z: 0 };
>Origin3d : Point3d
> : ^^^^^^^
>{ x: 0, y: 0, z: 0 } : { x: number; y: number; z: number; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>{ x: 0, y: 0, z: 0 } : Point3d
> : ^^^^^^^
>x : number
> : ^^^^^^
>0 : 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ module A {
export var Origin: Point = { x: 0, y: 0 };
>Origin : Point
> : ^^^^^
>{ x: 0, y: 0 } : { x: number; y: number; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
>{ x: 0, y: 0 } : Point
> : ^^^^^
>x : number
> : ^^^^^^
>0 : 0
Expand All @@ -46,8 +46,8 @@ module A {
export var Origin3d: Point3d = { x: 0, y: 0, z: 0 };
>Origin3d : Point3d
> : ^^^^^^^
>{ x: 0, y: 0, z: 0 } : { x: number; y: number; z: number; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>{ x: 0, y: 0, z: 0 } : Point3d
> : ^^^^^^^
>x : number
> : ^^^^^^
>0 : 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ module A {
export var Origin: Point = { x: 0, y: 0 };
>Origin : Point
> : ^^^^^
>{ x: 0, y: 0 } : { x: number; y: number; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
>{ x: 0, y: 0 } : Point
> : ^^^^^
>x : number
> : ^^^^^^
>0 : 0
Expand All @@ -38,8 +38,8 @@ module A {
export var Origin3d: Point3d = { x: 0, y: 0, z: 0 };
>Origin3d : Point3d
> : ^^^^^^^
>{ x: 0, y: 0, z: 0 } : { x: number; y: number; z: number; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>{ x: 0, y: 0, z: 0 } : Point3d
> : ^^^^^^^
>x : number
> : ^^^^^^
>0 : 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ module A {
export var Origin: Point = { x: 0, y: 0 };
>Origin : Point
> : ^^^^^
>{ x: 0, y: 0 } : { x: number; y: number; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
>{ x: 0, y: 0 } : Point
> : ^^^^^
>x : number
> : ^^^^^^
>0 : 0
Expand All @@ -38,8 +38,8 @@ module A {
export var Origin3d: Point3d = { x: 0, y: 0, z: 0 };
>Origin3d : Point3d
> : ^^^^^^^
>{ x: 0, y: 0, z: 0 } : { x: number; y: number; z: number; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>{ x: 0, y: 0, z: 0 } : Point3d
> : ^^^^^^^
>x : number
> : ^^^^^^
>0 : 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ module A {
export var Origin: Point = { x: 0, y: 0 };
>Origin : Point
> : ^^^^^
>{ x: 0, y: 0 } : { x: number; y: number; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
>{ x: 0, y: 0 } : Point
> : ^^^^^
>x : number
> : ^^^^^^
>0 : 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ module A {
export var Origin: Point = { x: 0, y: 0 };
>Origin : Point
> : ^^^^^
>{ x: 0, y: 0 } : { x: number; y: number; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
>{ x: 0, y: 0 } : Point
> : ^^^^^
>x : number
> : ^^^^^^
>0 : 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ module A {
export var Origin: Point = { x: 0, y: 0 };
>Origin : Point
> : ^^^^^
>{ x: 0, y: 0 } : { x: number; y: number; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
>{ x: 0, y: 0 } : Point
> : ^^^^^
>x : number
> : ^^^^^^
>0 : 0
Expand All @@ -40,8 +40,8 @@ module A {
export var Origin3d: Point3d = { x: 0, y: 0, z: 0 };
>Origin3d : Point3d
> : ^^^^^^^
>{ x: 0, y: 0, z: 0 } : { x: number; y: number; z: number; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>{ x: 0, y: 0, z: 0 } : Point3d
> : ^^^^^^^
>x : number
> : ^^^^^^
>0 : 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ var a: A.Color = A.Color.Red;
> : ^^^^^^^
>A : any
> : ^^^
>A.Color.Red : A.Color.Red
> : ^^^^^^^^^^^
>A.Color.Red : A.Color
> : ^^^^^^^
>A.Color : typeof A.Color
> : ^^^^^^^^^^^^^^
>A : typeof A
> : ^^^^^^^^
>Color : typeof A.Color
> : ^^^^^^^^^^^^^^
>Red : A.Color.Red
> : ^^^^^^^^^^^
>Red : A.Color
> : ^^^^^^^

// error not exported
var b = A.Day.Monday;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ module Geometry {
> : ^^^^^^^^^^^^
>Points : any
> : ^^^
>{ x: 0, y: 0 } : { x: number; y: number; }
> : ^^^^^^^^^^^^^^^^^^^^^^^^^
>{ x: 0, y: 0 } : Points.Point
> : ^^^^^^^^^^^^
>x : number
> : ^^^^^^
>0 : 0
Expand Down
Loading
Loading