TypeScript Define

process.env type define

add following code before `process.env.NODE_ENV`

1
2
3
4
5
6
7
declare var process : {
  env: {
    NODE_ENV: string
  }
}
 
process.env.NODE_ENV

define Array

1
2
3
4
5
6
7
8
9
10
11
export interface INinjaConfig {
    username: string;
    password: string;
    uris: {
      uri: string,
      pdfUri: string
    },
    mapping: {
      [key: string]: string;
    }
  }

define Array of Array Type

1
2
3
4
5
6
7
8
9
10
11
12
define [[string, number, number]...]
 
 
export interface IInfluxDBInfo {
    name: string,
    tags: {
      hostname: string,
      ifAlias: string
    },
    column: string[],
    values: Array<[string, number, number]>
}

nullable variable declare

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
export interface QueryConfig {
    limit?: number;
    skip?: number;
    sort?: {
        [key: string]: string;
    };
    select?: string;
    populate?: any;
    state?: string;
    lean?: boolean;
    handleNotFound?: boolean;
    archived?: boolean;
    publishEvent?: boolean;
    dataType?: string;
    all?: boolean;
    fields?: string[];
    childrens: [{
      sys_id: string;
      name: string;
      company: string;
    }];
}
This entry was posted in Javascript. Bookmark the permalink.