Skip to content

Instantly share code, notes, and snippets.

View richarddprasad's full-sized avatar
🎯
Focusing

Richard Prasad richarddprasad

🎯
Focusing
View GitHub Profile
import * as React from 'react';
function App() {
const canvasRef = React.useRef<HTMLCanvasElement>(null);
const [context, setContext] = React.useState<CanvasRenderingContext2D | null>(null);
React.useEffect(() => {
}, [context]);
function upperCaseFirst(inputStr) {
var valueOfFirstChar = inputStr.charCodeAt(0);
console.log('Value of first character:', valueOfFirstChar);
var upperCaseLetter = String.fromCharCode(valueOfFirstChar - 32);
console.log('Uppercase first character:', upperCaseLetter);
var restOfString = inputStr.slice(1);
console.log('Rest of the string:', restOfString);
import os from 'os';
const cpuInfo = os.cpus();
console.log(cpuInfo);
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
ReactDOM.render(<App name={"TypeScript Master"} />, document.getElementById('root'));
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
import React from 'react';
import logo from './logo.svg';
import './App.css';
interface AppProps {
name: string
}
const App: React.FC<AppProps> = ({ name }) => {
return (
// Basic types
var trueOrFalse: boolean;
var quantity: number;
var message: string;
var doNotKnowYet: undefined;
var nothingness: null;
var iCanBeAnything: any; // this is self-defeating!
// Typed arrays
var arrayOfStrings: string[];
{
"name": "from-js-to-ts",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build:dev": "tsc --watch --preserveWatchOutput",
"start": "node dist/index.js"
},
"scripts": {
"start:dev": "nodemon dist/index.js",
"build:dev": "tsc --watch --preserveWatchOutput",
"dev": "concurrently \"npm:build:dev\" \"npm:start:dev\"",
"postinstall": "tsc",
"start": "node dist/index.js"
},
import { DS } from './node';
export class LinkedList<T> {
private head: DS.Node<T>;
private tail: DS.Node<T>;
constructor() {
this.head = new DS.Node<T>();
this.tail = new DS.Node<T>();
this.head.next = this.tail;
import { LinkedList } from '../linked_list/linked_list';
export class StackList<T> {
private list: LinkedList<T>;
public constructor() {
this.list = new LinkedList<T>();
}
public isEmpty(): boolean {