From 56ab5afdc939215f6da91ce016b90596a510a90f Mon Sep 17 00:00:00 2001 From: Silei Xu Date: Tue, 29 Jun 2021 15:45:47 -0700 Subject: [PATCH] Use `Object.create(null)` to avoid inherit properties like `constructor` Object created from literal syntax will inherit properties from `Object.prototype`, which includes `constructor`. As a result, `lexcon['constructor']` will return a function object instead of undefined. --- src/lexicon.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lexicon.ts b/src/lexicon.ts index baca181..9099dd3 100644 --- a/src/lexicon.ts +++ b/src/lexicon.ts @@ -2,7 +2,7 @@ export interface LexiconType { [key:string]:string } -const lexicon = { +const lexicon = Object.assign(Object.create(null), { "!": "!", "#": "#", "...": ":", @@ -111980,6 +111980,6 @@ const lexicon = { "πŸ‡ΎπŸ‡ͺ": "EM", "πŸ‡ΏπŸ‡²": "EM", "πŸ‡ΏπŸ‡Ό": "EM" -} +}); export default lexicon; \ No newline at end of file