VSCode create unsaved file and add content

Try using openTextDocument with an untitled document to create a unsaved file at a given path, and then use WorkspaceEdit to add some text:

import * as vscode from 'vscode';
import * as path from 'path';

const newFile = vscode.Uri.parse('untitled:' + path.join(vscode.workspace.rootPath, 'safsa.txt'));
vscode.workspace.openTextDocument(newFile).then(document => {
    const edit = new vscode.WorkspaceEdit();
    edit.insert(newFile, new vscode.Position(0, 0), "Hello world!");
    return vscode.workspace.applyEdit(edit).then(success => {
        if (success) {
            vscode.window.showTextDocument(document);
        } else {
            vscode.window.showInformationMessage('Error!');
        }
    });
});

The new file will be unsaved when first opened, but saved to the given path when a user saves it.

Hope that provides a good starting point.