1 | /**
|
2 | * `getUntypedName` returns the name of the normal package
|
3 | * corresponding to a DefinitelyTyped package.
|
4 | */
|
5 | export function getUntypedName({ name }: { name: string }): string | undefined {
|
6 | if (!name.startsWith('@types/')) {
|
7 | return undefined;
|
8 | }
|
9 |
|
10 | // ['foo', undefined] or ['@bar', 'baz']
|
11 | const [scopeOrName, scopedName] = name.replace('@types/', '').split('__');
|
12 |
|
13 | return scopedName ? `@${scopeOrName}/${scopedName}` : scopeOrName;
|
14 | }
|