<commit_before>/* @internal */
namespace ts.codefix {
    registerCodeFix({
        errorCodes: [Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2.code,
                     Diagnostics.Cannot_find_name_0_Did_you_mean_1.code],
        getCodeActions: getActionsForCorrectSpelling
    });

    function getActionsForCorrectSpelling(context: CodeFixContext): CodeAction[] | undefined {
        const sourceFile = context.sourceFile;

        // This is the identifier of the misspelled word. eg:
        // this.speling = 1;
        //      ^^^^^^^
        const node = getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false); // TODO: GH#15852
        const checker = context.program.getTypeChecker();
        let suggestion: string;
        if (isPropertyAccessExpression(node.parent) && node.parent.name === node) {
            Debug.assert(node.kind === SyntaxKind.Identifier);
            const containingType = checker.getTypeAtLocation(node.parent.expression);
            suggestion = checker.getSuggestionForNonexistentProperty(node as Identifier, containingType);
        }
        else {
            const meaning = getMeaningFromLocation(node);
            const name = getTextOfNode(node);
            Debug.assert(!!name, "name should be defined");
            suggestion = checker.getSuggestionForNonexistentSymbol(node, name, convertSemanticMeaningToSymbolFlags(meaning));
        }
        if (suggestion) {
            return [{
                description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Change_spelling_to_0), [suggestion]),
                changes: [{
                    fileName: sourceFile.fileName,
                    textChanges: [{
                        span: { start: node.getStart(), length: node.getWidth() },
                        newText: suggestion
                    }],
                }],
            }];
        }
    }
<commit_msg>Use explicit undefined checkk<commit_after>/* @internal */
namespace ts.codefix {
    registerCodeFix({
        errorCodes: [Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2.code,
                     Diagnostics.Cannot_find_name_0_Did_you_mean_1.code],
        getCodeActions: getActionsForCorrectSpelling
    });

    function getActionsForCorrectSpelling(context: CodeFixContext): CodeAction[] | undefined {
        const sourceFile = context.sourceFile;

        // This is the identifier of the misspelled word. eg:
        // this.speling = 1;
        //      ^^^^^^^
        const node = getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false); // TODO: GH#15852
        const checker = context.program.getTypeChecker();
        let suggestion: string;
        if (isPropertyAccessExpression(node.parent) && node.parent.name === node) {
            Debug.assert(node.kind === SyntaxKind.Identifier);
            const containingType = checker.getTypeAtLocation(node.parent.expression);
            suggestion = checker.getSuggestionForNonexistentProperty(node as Identifier, containingType);
        }
        else {
            const meaning = getMeaningFromLocation(node);
            const name = getTextOfNode(node);
            Debug.assert(name !== undefined, "name should be defined");
            suggestion = checker.getSuggestionForNonexistentSymbol(node, name, convertSemanticMeaningToSymbolFlags(meaning));
        }
        if (suggestion) {
            return [{
                description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Change_spelling_to_0), [suggestion]),
                changes: [{
                    fileName: sourceFile.fileName,
                    textChanges: [{
                        span: { start: node.getStart(), length: node.getWidth() },
                        newText: suggestion
                    }],
                }],
            }];
        }
    }

{'fraction_non_alphanumeric': 0.09805427547363031, 'fraction_numerical': 0.006144393241167435, 'mean_word_length': 2.266722408026756, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1771390', 'n_tokens_mistral': 1026, 'n_tokens_neox': 999, 'n_words': 184}