Skip to content
Permalink
Browse files

fix(scope-manager): don't create a variable for global augmentation (#…

  • Loading branch information
yeonjuan committed Oct 6, 2020
1 parent c71f423 commit 6bc93257ec876214743a165093b6666d713379f6
@@ -347,6 +347,17 @@ const React = require('react');
`
type T = (value: unknown) => value is Id;
`,
`
global.foo = true;
declare global {
namespace NodeJS {
interface Global {
foo?: boolean;
}
}
}
`,
],
invalid: [
{
@@ -765,7 +765,7 @@ class Referencer extends Visitor {
}

protected TSModuleDeclaration(node: TSESTree.TSModuleDeclaration): void {
if (node.id.type === AST_NODE_TYPES.Identifier) {
if (node.id.type === AST_NODE_TYPES.Identifier && !node.global) {
this.currentScope().defineIdentifier(
node.id,
new TSModuleNameDefinition(node.id, node),
@@ -0,0 +1,3 @@
//// @sourceType = module

declare global {}
@@ -0,0 +1,42 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`ts-module global-augmentation 1`] = `
ScopeManager {
variables: Array [
ImplicitGlobalConstTypeVariable,
],
scopes: Array [
GlobalScope$1 {
block: Program$1,
isStrict: false,
references: Array [],
set: Map {
"const" => ImplicitGlobalConstTypeVariable,
},
type: "global",
upper: null,
variables: Array [
ImplicitGlobalConstTypeVariable,
],
},
ModuleScope$2 {
block: Program$1,
isStrict: true,
references: Array [],
set: Map {},
type: "module",
upper: GlobalScope$1,
variables: Array [],
},
TSModuleScope$3 {
block: TSModuleDeclaration$2,
isStrict: true,
references: Array [],
set: Map {},
type: "tsModule",
upper: ModuleScope$2,
variables: Array [],
},
],
}
`;

0 comments on commit 6bc9325

Please sign in to comment.
You can’t perform that action at this time.