Skip to content

Conversation

vladima
Copy link
Contributor

@vladima vladima commented Aug 13, 2014

LS now uses 2 instances of typechecker:

  • typeInfoResolver - created via getTypeChecker(/*fullTypeCheck*/ false) - used by quickinfo\dot completion etc..
  • fullTypeCheckChecker - created via getTypeChecker(/*fullTypeCheck*/ true) - used to get semantic diagnostics.

fullTypeCheck parameter in the getTypeChecker controls if typechecker can shortcut and answer more quickly (producing less error messages but they are still ignored when fullTypeCheck === true)

@@ -3945,7 +3944,7 @@ module ts {
var typeArgNode = typeArguments[i];
var typeArgument = getTypeFromTypeNode(typeArgNode);
var constraint = getConstraintOfTypeParameter(typeParameters[i]);
if (constraint) {
if (constraint && fullTypeCheck) {
checkTypeAssignableTo(typeArgument, constraint, typeArgNode, Diagnostics.Type_0_does_not_satisfy_the_constraint_1_Colon, Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we instead just augment checkTypeAssignableTo to check the fullTypeCheck flag?

@@ -1403,7 +1406,8 @@ module ts {

// Now create a new compiler
program = createProgram(hostfilenames, compilationSettings, createCompilerHost());
typeChecker = program.getTypeChecker();
typeInfoResolver = program.getTypeChecker(/*fullTypeCheckMode*/ false);
fullTypeCheckChecker = program.getTypeChecker(/*fullTypeCheckMode*/ true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not create it here. create it on demand. this will do a full bind, and unless the current operation is getSemanticDiagnositcs, this is wasted.

var typeInfoResolver: TypeChecker;
// the sole purpose of this checkes is to reutrn semantic diagnostics
// creation is deferred - use getFullTypeCheckChecker to get instance
var fullTypeCheckChecker_doNotAccessDirectly: TypeChecker;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i do not really care for the name that much. and this is used in only one place, so the extra layer of abstraction, is not really useful, i would just put it in getSemanticDiagnostics, to recreate if it does not exist and forget about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My preference in avoiding errors is to leave only one way that will do things right. Since accessing variable directly might fail without prior check - then this only was should be "always use function, do not touch the variable"

@mhegazy
Copy link
Contributor

mhegazy commented Aug 15, 2014

👍

vladima added a commit that referenced this pull request Aug 15, 2014
added fullTypeCheckFlag to TypeChecker
@vladima vladima merged commit a52cdaf into master Aug 15, 2014
@vladima vladima deleted the fullTypeCheckFlag branch August 15, 2014 19:14
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants