Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix watch mode #198

Merged
merged 1 commit into from Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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