diff --git a/libraries/adaptive-expressions/src/parser/expressionParser.ts b/libraries/adaptive-expressions/src/parser/expressionParser.ts index ce5d2d4ac9..e93fc7458b 100644 --- a/libraries/adaptive-expressions/src/parser/expressionParser.ts +++ b/libraries/adaptive-expressions/src/parser/expressionParser.ts @@ -27,7 +27,7 @@ export class ExpressionParser implements ExpressionParserInterface { */ readonly EvaluatorLookup: EvaluatorLookup; - private static expressionDict: Map = new Map(); + private static expressionDict: WeakMap = new WeakMap(); private readonly ExpressionTransformer = class extends AbstractParseTreeVisitor @@ -279,8 +279,8 @@ export class ExpressionParser implements ExpressionParserInterface { * @returns A ParseTree. */ protected static antlrParse(expression: string): ParseTree { - if (ExpressionParser.expressionDict.has(expression)) { - return ExpressionParser.expressionDict.get(expression); + if (ExpressionParser.expressionDict.has({ key: expression })) { + return ExpressionParser.expressionDict.get({ key: expression }); } const inputStream: ANTLRInputStream = new ANTLRInputStream(expression); @@ -297,7 +297,7 @@ export class ExpressionParser implements ExpressionParserInterface { if (file !== undefined) { expressionContext = file.expression(); } - ExpressionParser.expressionDict.set(expression, expressionContext); + ExpressionParser.expressionDict.set({ key: expression }, expressionContext); return expressionContext; } diff --git a/libraries/botbuilder-dialogs-adaptive/src/languageGeneratorExtensions.ts b/libraries/botbuilder-dialogs-adaptive/src/languageGeneratorExtensions.ts index d82a554a99..aac5b75e39 100644 --- a/libraries/botbuilder-dialogs-adaptive/src/languageGeneratorExtensions.ts +++ b/libraries/botbuilder-dialogs-adaptive/src/languageGeneratorExtensions.ts @@ -36,7 +36,7 @@ export const languagePolicyKey = Symbol('LanguagePolicy'); * Extension methods for language generator. */ export class LanguageGeneratorExtensions { - private static readonly _languageGeneratorManagers = new Map(); + private static readonly _languageGeneratorManagers = new WeakMap(); /** * Register default LG file or a language generator as default language generator.