Skip to content

Commit

Permalink
chore: fix watch mode (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikearnaldi committed Jun 22, 2022
1 parent 741b823 commit ca775d4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/compiler/builderState.ts
Expand Up @@ -224,6 +224,12 @@ namespace ts {
}
}

// TSPLUS START
for (const file of arrayFrom(program.getTypeChecker().getTsPlusFiles().values())) {
addReferencedFile(file.resolvedPath);
}
// TSPLUS END

// From ambient modules
for (const ambientModule of program.getTypeChecker().getAmbientModules()) {
if (ambientModule.declarations && ambientModule.declarations.length > 1) {
Expand Down
19 changes: 18 additions & 1 deletion src/compiler/checker.ts
Expand Up @@ -385,6 +385,7 @@ namespace ts {
const unificationInProgress = {
isRunning: false
};
const tsPlusFiles = new Set<SourceFile>();
// TSPLUS EXTENSION END

// Cancellation that controls whether or not we can cancel in the middle of type checking.
Expand Down Expand Up @@ -909,7 +910,8 @@ namespace ts {
.concat(collectTsPlusFluentTags(node))
.concat(collectTsPlusGetterTags(node))
.concat(collectTsPlusOperatorTags(node))
}
},
getTsPlusFiles: () => tsPlusFiles
// TSPLUS EXTENSION END
};

Expand Down Expand Up @@ -46568,6 +46570,7 @@ namespace ts {
function cacheTsPlusType(declaration: InterfaceDeclaration | TypeAliasDeclaration | ClassDeclaration): void {
const type = getTypeOfNode(declaration);
for (const typeTag of collectTsPlusTypeTags(declaration)) {
tsPlusFiles.add(getSourceFileOfNode(declaration));
if (type === globalStringType) {
addToTypeSymbolCache(tsplusStringPrimitiveSymbol, typeTag, "after");
}
Expand Down Expand Up @@ -46657,13 +46660,15 @@ namespace ts {
const tags = collectTsPlusCompanionTags(declaration);
if (type.symbol) {
for (const companionTag of tags) {
tsPlusFiles.add(getSourceFileOfNode(declaration));
addToCompanionSymbolCache(type.symbol, companionTag);
}
}
}
function cacheTsPlusStaticVariable(file: SourceFile, declaration: VariableDeclarationWithIdentifier) {
const staticTags = collectTsPlusStaticTags(declaration);
if (staticTags.length > 0) {
tsPlusFiles.add(getSourceFileOfNode(declaration));
const symbol = getSymbolAtLocation(declaration.name);
if (symbol) {
for (const { target, name } of staticTags) {
Expand All @@ -46686,6 +46691,7 @@ namespace ts {
function cacheTsPlusFluentVariable(file: SourceFile, declaration: VariableDeclarationWithIdentifier) {
const fluentTags = collectTsPlusFluentTags(declaration);
for (const tag of fluentTags) {
tsPlusFiles.add(getSourceFileOfNode(declaration));
if (!unresolvedFluentCache.has(tag.target)) {
unresolvedFluentCache.set(tag.target, new Map());
}
Expand Down Expand Up @@ -46734,6 +46740,7 @@ namespace ts {
if(declaration.name && isIdentifier(declaration.name)) {
const operatorTags = collectTsPlusOperatorTags(declaration);
if (operatorTags.length > 0) {
tsPlusFiles.add(getSourceFileOfNode(declaration));
const symbol = getSymbolAtLocation(declaration.name);
if (symbol) {
for (const tag of operatorTags) {
Expand Down Expand Up @@ -46761,6 +46768,7 @@ namespace ts {
const symbol = getSymbolAtLocation(declaration.name);
if (symbol) {
for (const tag of operatorTags) {
tsPlusFiles.add(getSourceFileOfNode(declaration));
if (!operatorCache.has(tag.target)) {
operatorCache.set(tag.target, new Map());
}
Expand All @@ -46781,6 +46789,7 @@ namespace ts {
function cacheTsPlusFluentFunction(file: SourceFile, declaration: FunctionDeclaration) {
const fluentTags = collectTsPlusFluentTags(declaration);
for (const tag of fluentTags) {
tsPlusFiles.add(getSourceFileOfNode(declaration));
if (!unresolvedFluentCache.has(tag.target)) {
unresolvedFluentCache.set(tag.target, new Map());
}
Expand Down Expand Up @@ -46812,6 +46821,7 @@ namespace ts {
if (declaration.name && isIdentifier(declaration.name)) {
const pipeableTags = collectTsPlusPipeableTags(declaration);
for (const { target, name } of pipeableTags) {
tsPlusFiles.add(getSourceFileOfNode(declaration));
if (!pipeableCache.has(target)) {
pipeableCache.set(target, new Map());
}
Expand Down Expand Up @@ -46855,6 +46865,7 @@ namespace ts {
if((declaration.initializer && isFunctionLikeDeclaration(declaration.initializer)) ||
(declaration.type && isFunctionTypeNode(declaration.type))) {
for (const { target, name } of collectTsPlusPipeableTags(declaration)) {
tsPlusFiles.add(getSourceFileOfNode(declaration));
if (!pipeableCache.has(target)) {
pipeableCache.set(target, new Map());
}
Expand Down Expand Up @@ -46902,6 +46913,7 @@ namespace ts {
function cacheTsPlusGetterFunction(file: SourceFile, declaration: FunctionDeclaration) {
if(declaration.name && isIdentifier(declaration.name)) {
for (const { target, name } of collectTsPlusGetterTags(declaration)) {
tsPlusFiles.add(getSourceFileOfNode(declaration));
if (!getterCache.has(target)) {
getterCache.set(target, new Map());
}
Expand All @@ -46918,6 +46930,7 @@ namespace ts {
function cacheTsPlusStaticFunction(file: SourceFile, declaration: FunctionDeclaration) {
if(declaration.name && isIdentifier(declaration.name)) {
for (const { target, name } of collectTsPlusStaticTags(declaration)) {
tsPlusFiles.add(getSourceFileOfNode(declaration));
if (!staticCache.has(target)) {
staticCache.set(target, new Map());
}
Expand Down Expand Up @@ -46954,13 +46967,16 @@ namespace ts {
function cacheTsPlusUnifyFunction(declaration: FunctionDeclaration) {
if(declaration.name && isIdentifier(declaration.name)) {
for (const target of collectTsPlusUnifyTags(declaration)) {
tsPlusFiles.add(getSourceFileOfNode(declaration));
identityCache.set(target, declaration);
}
}
}
function cacheTsPlusIndexFunction(declaration: FunctionDeclaration) {
if(declaration.name && isIdentifier(declaration.name)) {
for (const target of collectTsPlusIndexTags(declaration)) {
tsPlusFiles.add(getSourceFileOfNode(declaration));
tsPlusFiles.add(getSourceFileOfNode(declaration));
indexCache.set(target, {
declaration,
definition: getSourceFileOfNode(declaration),
Expand Down Expand Up @@ -47083,6 +47099,7 @@ namespace ts {
staticValueCache.clear();
unresolvedStaticCache.clear();
identityCache.clear();
tsPlusFiles.clear();
getterCache.clear();
callCache.clear();
indexCache.clear();
Expand Down
3 changes: 3 additions & 0 deletions src/compiler/types.ts
Expand Up @@ -4963,13 +4963,16 @@ namespace ts {
getPrimitiveTypeName(type: Type): string | undefined
getResolvedOperator(node: BinaryExpression): Signature | undefined
getNodeLinks(node: Node): NodeLinks
// TSPLUS START
getTsPlusFiles(): Set<SourceFile>
collectTsPlusMacroTags(statement: Declaration): readonly string[]
getTsPlusGlobals(): Symbol[];
getTsPlusGlobal(name: string): TsPlusGlobalImport | undefined;
findAndCheckDoAncestor(node: Node): void;
getTsPlusExtensionsAtLocation(node: Node): TsPlusExtensionTag[];
getTsPlusSymbolAtLocation(node: Node): TsPlusSymbol | undefined;
getExtensionsForDeclaration(node: Declaration): TsPlusExtensionTag[]
// TSPLUS END
}

/* @internal */
Expand Down

0 comments on commit ca775d4

Please sign in to comment.