Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

124
Views
How to import a single property named with dot notation from package.json?

SonarQube detects the following code as a mistake ("Wildcard imports should not be used") :

import * as packageJson from '../../../package.json';

We use only a few of properties contained in package.json

For instance, no problem for the version, I can use that :

import { version } from '../../../package.json';

In our package.json , I want to use a property named with dot notation :

...
"project.id": "123456",
...

But the following import gives me a compilation error :

import {['project.id'] as projectId } from '../../../package.json';
error TS1141: String literal expected.

How to get correctly this single project.id property from package.json ? I don't want to rename it.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

One solution you can change project in your package.json as below

"project":  {
   "id": "123456"
 }

and import like

import { project } from '../../project.json';
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!