demo/typescript.js
function checkSourceFileWorker(node) {
            var links = getNodeLinks(node);
            if (!(links.flags & 1 /* TypeChecked */)) {
                // Check whether the file has declared it is the default lib,
                // and whether the user has specifically chosen to avoid checking it.
                if (node.isDefaultLib && compilerOptions.skipDefaultLibCheck) {
                    return;
                }
                // Grammar checking
                checkGrammarSourceFile(node);
                emitExtends = false;
                emitDecorate = false;
                emitParam = false;
                potentialThisCollisions.length = 0;
                ts.forEach(node.statements, checkSourceElement);
                checkFunctionAndClassExpressionBodies(node);
                if (ts.isExternalModule(node)) {
                    checkExternalModuleExports(node);
                }
                if (potentialThisCollisions.length) {
                    ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope);
                    potentialThisCollisions.length = 0;
                }
                if (emitExtends) {
                    links.flags |= 8 /* EmitExtends */;
                }
                if (emitDecorate) {
                    links.flags |= 16 /* EmitDecorate */;
                }
                if (emitParam) {
                    links.flags |= 32 /* EmitParam */;
                }
                if (emitAwaiter) {
                    links.flags |= 64 /* EmitAwaiter */;
                }
                if (emitGenerator || (emitAwaiter && languageVersion < 2 /* ES6 */)) {
                    links.flags |= 128 /* EmitGenerator */;
                }
                links.flags |= 1 /* TypeChecked */;
            }
        }
function checkSourceFileWorker(node) {
            var links = getNodeLinks(node);
            if (!(links.flags & 1 /* TypeChecked */)) {
                // Check whether the file has declared it is the default lib,
                // and whether the user has specifically chosen to avoid checking it.
                if (node.isDefaultLib && compilerOptions.skipDefaultLibCheck) {
                    return;
                }
                // Grammar checking
                checkGrammarSourceFile(node);
                emitExtends = false;
                emitDecorate = false;
                emitParam = false;
                potentialThisCollisions.length = 0;
                ts.forEach(node.statements, checkSourceElement);
                checkFunctionAndClassExpressionBodies(node);
                if (ts.isExternalModule(node)) {
                    checkExternalModuleExports(node);
                }
                if (potentialThisCollisions.length) {
                    ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope);
                    potentialThisCollisions.length = 0;
                }
                if (emitExtends) {
                    links.flags |= 8 /* EmitExtends */;
                }
                if (emitDecorate) {
                    links.flags |= 16 /* EmitDecorate */;
                }
                if (emitParam) {
                    links.flags |= 32 /* EmitParam */;
                }
                if (emitAwaiter) {
                    links.flags |= 64 /* EmitAwaiter */;
                }
                if (emitGenerator || (emitAwaiter && languageVersion < 2 /* ES6 */)) {
                    links.flags |= 128 /* EmitGenerator */;
                }
                links.flags |= 1 /* TypeChecked */;
            }
        }
Fully type check a source file and collect the relevant diagnostics.