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

210
Views
What is the interface type format in the angular cli?

I was looking at the docs and became lost.

ng generate interface <name> <type>

However it doesn't tell what to put in for type. Like is it just a string, object, array, etc or can I specify properties like email:String username:String age:Number?

about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

ng generate will generate

filename <name>.<type>.ts content:

export interface <name> { //camel case

}

ie

ng generate interface Itest sometype generates file name itest.sometype.ts content

export interface Itest {
}
about 4 years ago · Santiago Trujillo Report

0

Using Angular CLI,

ng g i filename

will create a file by the name filename.ts and will have export interface filename {} in it

about 4 years ago · Santiago Trujillo Report

0

Like so :

interface GraphDatas {
  firstTemperature: Period
  internalTemperature: {
    min: number;
    max: number;
  };
  secondTemperature: Period;
  thresholdAlerts: Threshold;
}

interface Period {
  currentPeriod: number;
  previousPeriod: any;  // TO DO
}

interface Threshold extends Period {
  hasBeenRead: number;
}

You will need to export the interface you want to use in your typescript file after that :

export interface test{
  listComputedDatas: GraphDatas;
}

And in your code :

import {test} from './pathToInterface';

...

randomProperty: test;
// Typescript should detect properties such as 
// randomProperty.listComputedDatas.internalTemperature.min

EDIT : You will be faster creating your own file manually than doing the angular-cli command...

about 4 years ago · Santiago Trujillo 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!