Skip to content

No merge for redirected source files in initializeTypeChecker #25463

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27700,6 +27700,9 @@ namespace ts {
// Initialize global symbol table
let augmentations: ReadonlyArray<StringLiteral | Identifier>[] | undefined;
for (const file of host.getSourceFiles()) {
if (file.redirectInfo) {
continue;
}
if (!isExternalOrCommonJsModule(file)) {
mergeSymbolTable(globals, file.locals!);
}
Expand Down
31 changes: 31 additions & 0 deletions tests/baselines/reference/duplicatePackage_globalMerge.errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/node_modules/@types/react/index.d.ts(1,9): error TS2669: Augmentations for the global scope can only be directly nested in external modules or ambient module declarations.
/src/index.ts(1,24): error TS2306: File '/node_modules/@types/react/index.d.ts' is not a module.
/tests/index.ts(1,24): error TS2306: File '/tests/node_modules/@types/react/index.d.ts' is not a module.


==== /src/bug25410.ts (0 errors) ====
import { x } from './index'
import { y } from '../tests/index'

==== /src/index.ts (1 errors) ====
import * as React from 'react';
~~~~~~~
!!! error TS2306: File '/node_modules/@types/react/index.d.ts' is not a module.
export var x = 1
==== /tests/index.ts (1 errors) ====
import * as React from 'react';
~~~~~~~
!!! error TS2306: File '/tests/node_modules/@types/react/index.d.ts' is not a module.
export var y = 2

==== /tests/node_modules/@types/react/package.json (0 errors) ====
{ "name": "@types/react", "version": "16.4.6" }
==== /tests/node_modules/@types/react/index.d.ts (0 errors) ====

==== /node_modules/@types/react/package.json (0 errors) ====
{ "name": "@types/react", "version": "16.4.6" }
==== /node_modules/@types/react/index.d.ts (1 errors) ====
declare global { }
~~~~~~
!!! error TS2669: Augmentations for the global scope can only be directly nested in external modules or ambient module declarations.

34 changes: 34 additions & 0 deletions tests/baselines/reference/duplicatePackage_globalMerge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//// [tests/cases/compiler/duplicatePackage_globalMerge.ts] ////

//// [index.ts]
import * as React from 'react';
export var x = 1
//// [index.ts]
import * as React from 'react';
export var y = 2

//// [package.json]
{ "name": "@types/react", "version": "16.4.6" }
//// [index.d.ts]

//// [package.json]
{ "name": "@types/react", "version": "16.4.6" }
//// [index.d.ts]
declare global { }

//// [bug25410.ts]
import { x } from './index'
import { y } from '../tests/index'


//// [index.js]
"use strict";
exports.__esModule = true;
exports.x = 1;
//// [index.js]
"use strict";
exports.__esModule = true;
exports.y = 2;
//// [bug25410.js]
"use strict";
exports.__esModule = true;
29 changes: 29 additions & 0 deletions tests/baselines/reference/duplicatePackage_globalMerge.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
=== /src/bug25410.ts ===
import { x } from './index'
>x : Symbol(x, Decl(bug25410.ts, 0, 8))

import { y } from '../tests/index'
>y : Symbol(y, Decl(bug25410.ts, 1, 8))

=== /src/index.ts ===
import * as React from 'react';
>React : Symbol(React, Decl(index.ts, 0, 6))

export var x = 1
>x : Symbol(x, Decl(index.ts, 1, 10))

=== /tests/index.ts ===
import * as React from 'react';
>React : Symbol(React, Decl(index.ts, 0, 6))

export var y = 2
>y : Symbol(y, Decl(index.ts, 1, 10))

=== /tests/node_modules/@types/react/index.d.ts ===

>global : Symbol(global, Decl(index.d.ts, 0, 0))

=== /node_modules/@types/react/index.d.ts ===
declare global { }
>global : Symbol(global, Decl(index.d.ts, 0, 0))

31 changes: 31 additions & 0 deletions tests/baselines/reference/duplicatePackage_globalMerge.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
=== /src/bug25410.ts ===
import { x } from './index'
>x : number

import { y } from '../tests/index'
>y : number

=== /src/index.ts ===
import * as React from 'react';
>React : any

export var x = 1
>x : number
>1 : 1

=== /tests/index.ts ===
import * as React from 'react';
>React : any

export var y = 2
>y : number
>2 : 2

=== /tests/node_modules/@types/react/index.d.ts ===

>global : typeof global

=== /node_modules/@types/react/index.d.ts ===
declare global { }
>global : typeof global

21 changes: 21 additions & 0 deletions tests/cases/compiler/duplicatePackage_globalMerge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// @noImplicitReferences: true

// @Filename: /src/index.ts
import * as React from 'react';
export var x = 1
// @Filename: /tests/index.ts
import * as React from 'react';
export var y = 2

// @Filename: /tests/node_modules/@types/react/package.json
{ "name": "@types/react", "version": "16.4.6" }
// @Filename: /tests/node_modules/@types/react/index.d.ts

// @Filename: /node_modules/@types/react/package.json
{ "name": "@types/react", "version": "16.4.6" }
// @Filename: /node_modules/@types/react/index.d.ts
declare global { }

// @Filename: /src/bug25410.ts
import { x } from './index'
import { y } from '../tests/index'