Add cloneDeepWithoutLoc (#10680)

* feat: add cloneDeepWithoutLoc

* fix: sort functions alphabetically

* doc: add documentation for the withoutLoc parameter

* test: add a test for  shallow cloneWithoutLoc

* test: add loc object to node and fix test

* fix: set loc object on deeper node

* test: check loc on deeper node is null

* doc: adjust withoutLoc documentation

* fix: add withoutLoc param to deep clones

* fix: apply cloneIfNodeOrArray for leadingComments, innerComments and trailingComments

* test: add test for leadingComments, innerComments and trailingComments

* Cleanup PR

Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
This commit is contained in:
Taym Haddadi
2020-03-16 23:07:01 +01:00
committed by GitHub
parent f232d4d109
commit 286aaeadd9
7 changed files with 135 additions and 30 deletions

View File

@@ -135,7 +135,8 @@ lines.push(
// clone/
`declare function clone<T>(n: T): T;`,
`declare function cloneDeep<T>(n: T): T;`,
`declare function cloneNode<T>(n: T, deep?: boolean): T;`,
`declare function cloneDeepWithoutLoc<T>(n: T): T;`,
`declare function cloneNode<T>(n: T, deep?: boolean, withoutLoc?: boolean): T;`,
`declare function cloneWithoutLoc<T>(n: T): T;`,
// comments/

View File

@@ -154,7 +154,8 @@ lines.push(
// clone/
`export function clone<T extends Node>(n: T): T;`,
`export function cloneDeep<T extends Node>(n: T): T;`,
`export function cloneNode<T extends Node>(n: T, deep?: boolean): T;`,
`export function cloneDeepWithoutLoc<T extends Node>(n: T): T;`,
`export function cloneNode<T extends Node>(n: T, deep?: boolean, withoutLoc?: boolean): T;`,
`export function cloneWithoutLoc<T extends Node>(n: T): T;`,
// comments/