Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TypeScript: detect node built-in type usage (#445)
Issue #444
- Loading branch information
Showing
4 changed files
with
14 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
import lodash from 'lodash'; | ||
import builtInModules from 'builtin-modules'; | ||
|
||
/* eslint-disable import/prefer-default-export */ | ||
const orgDepRegex = /@(.*?)\/(.*)/; | ||
|
||
// The name of the DefinitelyTyped package for a given package | ||
export function getAtTypesName(dep) { | ||
const match = orgDepRegex.exec(dep); | ||
const pkgName = match ? `${match[1]}__${match[2]}` : dep; | ||
|
||
let pkgName; | ||
if (lodash.includes(builtInModules, dep)) { | ||
pkgName = 'node'; | ||
} else { | ||
const match = orgDepRegex.exec(dep); | ||
pkgName = match ? `${match[1]}__${match[2]}` : dep; | ||
} | ||
return `@types/${pkgName}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import Dep from 'ts-dep-esnext'; | ||
import '@org/org-pkg'; | ||
import * as path from 'path'; | ||
|
||
export const ObjRestSpread = () => { | ||
const a = {a: 1, b: 2}; | ||
const { b, ...rest } = a; | ||
const c = {...a, ...rest}; | ||
path.resolve('/', 'home'); | ||
new Dep(c); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters