【发布时间】:2023-03-24 13:43:01
【问题描述】:
我已经设置了一些 sn-p 并按照我的意愿工作,但是我很难让一个 sn-p 在我认为需要进行多次转换的地方工作?
基本上我为我的一个组件定义了一个 TypeScript 接口。
即IRadioButtonListProps.ts 位于 Interfaces 文件夹内。 Interfaces 文件夹有一个名为 Theme 的同级文件夹,其中包含一个名为 IRadioButtonListTheme.ts 的接口
在IRadioButtonListProps 内部,我正在尝试删除整个界面。我目前的 sn-p 将接口存根,例如...
import * as React from 'react';
import IRadioButtonListPropsTheme from '../Theme/IRadioButtonListPropsTheme';
export interface IRadioButtonListPropsProps {
...props...
}
export default IRadioButtonListPropsProps;
sn-p里面的导入行是...
"import I${TM_FILENAME_BASE/(.*)\\..+$/$1/}Props from './Interfaces/I${TM_FILENAME_BASE/(.*)\\..+$/$1/}Props';"
我试图发生但似乎无法弄清楚的是如何删除“道具”一词。所以我会得到 import import IRadioButtonListTheme... 而不是 import IRadioButtonListPropsTheme...。
同时,我想删除所有扩展名,包括 *.abc.abc(“两个”扩展名)和 *.abc(一个简单扩展名)形式的扩展名。
这可能吗?
【问题讨论】:
-
(.*)\\..+$应该匹配什么? -
code.visualstudio.com/docs/editor/… 如果文件名有扩展名,这将删除扩展名。
-
尝试将
(.*)\\..+$更改为(.*?)(?:Props)?\\.[^.]+$ -
这并没有像我尝试的那样中断,但它也没有改变输出。