Skip to content

Commit

Permalink
learn-typescript: indexable types
Browse files Browse the repository at this point in the history
  • Loading branch information
kherin committed Mar 29, 2024
1 parent b071b08 commit 33df0da
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion typescript/module01.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
<h1>Test JavaScript</h1>
<p id="date"></p>
<p>This page calls the script module03.js and is used for testing.</p>
<script src="./build/module04.js"></script>
<script src="./build/module06.js"></script>
</body>
</html>
18 changes: 18 additions & 0 deletions typescript/module06.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
interface Sundae extends IceCream {
sauce: 'chocolate' | 'caramel' | 'strawberry';
nuts?: boolean;
whippedCream?: boolean;
instructions?: boolean;
}


interface IceCreamArray {
[index: number]: string;
}

let myIceCreamList: IceCreamArray;

myIceCreamList = ['chocolate', 'caramel', 'strawberry'];

let myStr: string = myIceCreamList[0];
console.log({ myStr });

0 comments on commit 33df0da

Please sign in to comment.