Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: #125 - Inserting a namespace or class into an ambient module/nam…
…espace should not write as non-ambient.
- Loading branch information
Showing
8 changed files
with
63 additions
and
23 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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Node } from "../../compiler"; | ||
import { ts } from "../../typescript"; | ||
import { TypeGuards } from "../TypeGuards"; | ||
|
||
export function isNodeAmbientOrInAmbientContext(node: Node) { | ||
if (checkNodeIsAmbient(node) || node.sourceFile.isDeclarationFile()) | ||
return true; | ||
|
||
for (const ancestor of node.getAncestorsIterator(false)) { | ||
if (checkNodeIsAmbient(ancestor)) | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
function checkNodeIsAmbient(node: Node) { | ||
const isThisAmbient = (node.getCombinedModifierFlags() & ts.ModifierFlags.Ambient) === ts.ModifierFlags.Ambient; | ||
return isThisAmbient || TypeGuards.isInterfaceDeclaration(node) || TypeGuards.isTypeAliasDeclaration(node); | ||
} |