0

ts代码:

import { Component } from '@angular/core';
import { Column } from 'ng-custom';

interface NameObject {
  name: string;
}

@Component({
  selector: 'app-list',
  templateUrl: './list.component.html',
  styleUrls: ['./list.component.scss']
})
export class ListComponent {
  nameObject: NameObject = {
    name: 'Name'
  }
  name: string = 'Name';
  columns: Column[] = [
    {
      name: 'Name',
    },
  ];

  constructor() { }
}

jscodeshift代码:

 const file = require("file-system");
    const fs = require("fs");
    const path = require("path");
    const jscodeshift = require("jscodeshift");
    const j = jscodeshift.withParser("tsx");
    
    const FOLDER = path.resolve(
      __dirname,
      "src",
    );
    
    file.recurseSync(
      FOLDER,
      ["**/*.tsx"],
      function (filepath, relative, isFile) {
        if (!isFile) {
          return;
        }
        const fileContents = fs.readFileSync(filepath, "utf-8");
        j(fileContents).find(j.StringLiteral).filter(item => {
          console.log(item.value.value);
        });
      },
    );

我需要将代码中的'Name'改成其他文案,但只需要修改'columns'中的'Name','nameObject'和'name'不需要修改,怎么找变量type(NameObject, string, Column[]) 判断是否需要修改?

4

0 回答 0