Languages

Object.entries() in TypeScript not working

7 points
Asked by:
Mariam-Barron
391

As in topic.

I thought that TypeScript supports by default Object.entries(object).

1 answer
5 points
Answered by:
Mariam-Barron
391

I am almost 100% sure that you don't have defined es2017.object lib in tsconfig.json. ECMAScript 2017 (ES8) intoduced Object.entries(object).

Example tsconfig.json file:

{
	"version": "4.0.3",
	"compilerOptions": {
		"strict": true,
		"target": "es5",
		"module": "amd",
		"composite": false,
		"declaration": false,
		"lib": ["es2015.promise", "es2017.object", "dom", "es5"],
		"allowJs": true,
		"removeComments": true,
		"noImplicitAny": true,
		"noImplicitReturns": true,
		"preserveConstEnums": true,
		"strictBindCallApply": true,
		"sourceMap": true
	},
	"include": [
		"src/**/*.ts"
	],
	"exclude": [
		"src/**/*.d.ts"
	]
}

Or you can use all es2017 set ("lib": ["es2015.promise", "es2017", "dom", "es5"]).

0 comments Add comment
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join