Skip to content

Instantly share code, notes, and snippets.

function useLocalModal() {
const [modalNode, setModalNode] = useState<ReactNode>(null);
const openModal = useCallback(function openModal<ResultType>(
renderModal: (close: (result: ResultType) => void) => ReactNode
): Promise<ResultType> {
return new Promise(resolve => {
function close(result: ResultType) {
setModalNode(null);
resolve(result);
const fs = require('fs');
const path = require('path');
async function main() {
const pathsFile = await fs.promises.readFile(path.join(__dirname, 'paths'));
const paths = pathsFile
.toString('utf8')
.split(/\r\n?/)
.map(line => line.trim())
.filter(line => line !== '');
// Live Coding: Iterables and why you should care
// This object implements the iterable interface.
// It has a function in the property [Symbol.iterator] that returns an iterator
let iterable = {
[Symbol.iterator]: () => {
// The iterator is an object that has a function in the property next that returns an interator result
let iterator = {
next: () => {
@andrewgreenh
andrewgreenh / tsserver.log
Created April 6, 2018 06:10
Next reproduction with VSCode 1.22.1 and --disable-extensions
This file has been truncated, but you can view the full file.
Info 0 [8:5:48.391] Starting TS Server
Info 1 [8:5:48.393] Version: 2.8.1
Info 2 [8:5:48.393] Arguments: C:\Program Files\Microsoft VS Code\Code.exe c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js --useInferredProjectPerProjectRoot --enableTelemetry --cancellationPipeName C:\Users\andreas\AppData\Local\Temp\vscode-tscancellation-289faa239d7d7b65ab20.sock* --logVerbosity verbose --logFile C:\Users\andreas\AppData\Roaming\Code\logs\20180406T080542\vscode.typescript-language-features_1\tsserver-log-aa2mQZ\tsserver.log --locale en
Info 3 [8:5:48.393] Platform: win32 NodeVersion: 7 CaseSensitive: false
Info 4 [8:5:48.397] Provided types map file "c:/Program Files/Microsoft VS Code/resources/app/extensions/node_modules/typescript/lib/tsserver.js/../typesMap.json" doesn't exist
Info 5 [8:5:48.397] Binding...
Info 6 [8:5:48.407] event:
{"seq":0,"type":"event","event":"typingsInstallerPid","body":{"pid":14904}}
@andrewgreenh
andrewgreenh / tsserver.log
Created April 5, 2018 16:29
tsserver.log when Intellisense stops working
This file has been truncated, but you can view the full file.
Info 0 [18:12:53.894] Starting TS Server
Info 1 [18:12:53.896] Version: 2.7.2
Info 2 [18:12:53.896] Arguments: C:\Program Files\Microsoft VS Code\Code.exe c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js --useInferredProjectPerProjectRoot --enableTelemetry --cancellationPipeName C:\Users\andreas\AppData\Local\Temp\vscode-tscancellation-8ad8445abf7352f66882.sock* --logVerbosity verbose --logFile C:\Users\andreas\AppData\Roaming\Code\logs\20180405T180612\vscode.typescript-language-features_1\tsserver-log-8CBadF\tsserver.log --locale en
Info 3 [18:12:53.896] Platform: win32 NodeVersion: 7 CaseSensitive: false
Info 4 [18:12:53.902] Provided types map file "c:/Program Files/Microsoft VS Code/resources/app/extensions/node_modules/typescript/lib/tsserver.js/../typesMap.json" doesn't exist
Info 5 [18:12:53.943] Binding...
Info 6 [18:12:53.983] event:
{"seq":0,"type":"event","event":"typingsInstallerPid","body":{"pid":8720}}