Skip to content

Instantly share code, notes, and snippets.

@yunghoy
Last active January 12, 2020 15:11
Show Gist options
  • Select an option

  • Save yunghoy/71d7768d4170e78a3dff7a09c3a313e5 to your computer and use it in GitHub Desktop.

Select an option

Save yunghoy/71d7768d4170e78a3dff7a09c3a313e5 to your computer and use it in GitHub Desktop.

Revisions

  1. yunghoy revised this gist Jan 12, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion types.ts
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,7 @@ From the codes I wrote 3 years ago. Find code from my cloud storage.
    };
    console.log(JSON.stringify(test2));

    interface KeyValue3 {
    interface KeyValue3 { // Actually, key field in the definition of type is not that important.
    [a: string]: string;
    }
    const test3: KeyValue3 = {
  2. yunghoy renamed this gist Jan 12, 2020. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. yunghoy created this gist Jan 12, 2020.
    48 changes: 48 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    From the codes I wrote 3 years ago. Find code from my cloud storage.

    interface KeyValue1 {
    [key: string]: string[];
    }
    const test1: KeyValue1 = {
    "key1": ["value1"],
    "key2": ["value2"],
    };
    console.log(JSON.stringify(test1));

    interface KeyValue2 {
    [key: string]: string;
    }
    const test2: KeyValue2 = {
    "key1": "value1",
    "key2": "value2",
    };
    console.log(JSON.stringify(test2));

    interface KeyValue3 {
    [a: string]: string;
    }
    const test3: KeyValue3 = {
    "key1": "value1",
    "key2": "value2",
    };
    console.log(JSON.stringify(test3));

    interface KeyValue4 {
    [key: number]: string;
    }
    const test4: KeyValue4 = {
    1: "value1",
    2: "value2",
    };
    console.log(JSON.stringify(test4));

    const test11: KeyValue1[] = [
    {
    "key1": ["value1"],
    "key2": ["value2"],
    }, {
    "key3": ["value3"],
    "key4": ["value4"],
    }
    ];
    console.log(JSON.stringify(test11));