Public paste
testing ts
By: kostja | Date: Nov 17 2017 21:07 | Format: None | Expires: never | Size: 1005 B | Hits: 727

  1. tsconfig.json
  2. {
  3.     "compilerOptions": {
  4.     "target": "es6",
  5.     "module": "es6",
  6.     "sourceMap": true
  7.     }
  8. }
  9.  
  10. main.ts
  11. import * as d3 from "d3";
  12.  
  13. function main() : void {
  14.     console.log('hi');
  15.    
  16.     //let rowsNumber = 1;
  17.     //let rows = new Array<number>(rowsNumber);
  18.     //for (let i = 0; i < rowsNumber; ++i)
  19.     //    rows[i] = i;
  20.     d3.select('body').selectAll('.rows')
  21.         .data([0, 1, 2]).enter()
  22.         .text((data, index) => index.toString());
  23.    
  24.     // const div = document.createElement('div');
  25.     // div.textContent = 'Hello';
  26.     // document.body.appendChild(div);
  27. }
  28.  
  29. document.addEventListener("DOMContentLoaded", (e) => main());    
  30.  
  31. index.html
  32. <!DOCTYPE html>
  33. <html lang="en">
  34. <head>
  35.     <meta charset="UTF-8">
  36.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  37.  
  38.     <script type="module">
  39.         import './main.js';
  40.     </script>
  41.  
  42.     <title>Testing TypeScript</title>
  43. </head>
  44. <body>
  45.  
  46. </body>
  47. </html>
  48.