forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #121 from bloomberg/isolated-declarations-unused-i…
…mports Revert change in checker that prevented TS from removing some imports
- Loading branch information
Showing
13 changed files
with
398 additions
and
7 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
17 changes: 17 additions & 0 deletions
17
...declarations/original/diff/decoratorMetadataWithImportDeclarationNameCollision7.d.ts.diff
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,17 @@ | ||
// [[Reason: TSC removes import that is not used in a semantically valid way. DTE can't know about this.]] //// | ||
|
||
//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision7.ts] //// | ||
|
||
=================================================================== | ||
--- TSC declarations | ||
+++ DTE declarations | ||
@@ -5,8 +5,9 @@ | ||
doSomething(): invalid; | ||
} | ||
|
||
//// [service.d.ts] | ||
+import db from './db'; | ||
declare class MyClass { | ||
db: db.db; | ||
constructor(db: db.db); | ||
} |
16 changes: 16 additions & 0 deletions
16
...selines/reference/isolated-declarations/original/diff/typeReferenceDirectives13.d.ts.diff
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,16 @@ | ||
// [[Reason: TSC removes type only import. DTE can't know import is type only.]] //// | ||
|
||
//// [tests/cases/compiler/typeReferenceDirectives13.ts] //// | ||
|
||
=================================================================== | ||
--- TSC declarations | ||
+++ DTE declarations | ||
@@ -1,7 +1,8 @@ | ||
|
||
|
||
//// [/app.d.ts] | ||
+import { $ } from "./ref"; | ||
export interface A { | ||
x: () => typeof $; | ||
} | ||
|
16 changes: 16 additions & 0 deletions
16
...aselines/reference/isolated-declarations/original/diff/typeReferenceDirectives5.d.ts.diff
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,16 @@ | ||
// [[Reason: TSC removes type only import. DTE can't know import is type only.]] //// | ||
|
||
//// [tests/cases/compiler/typeReferenceDirectives5.ts] //// | ||
|
||
=================================================================== | ||
--- TSC declarations | ||
+++ DTE declarations | ||
@@ -1,7 +1,8 @@ | ||
|
||
|
||
//// [/app.d.ts] | ||
+import { $ } from "./ref"; | ||
export interface A { | ||
x: typeof $; | ||
} | ||
|
83 changes: 83 additions & 0 deletions
83
...lated-declarations/original/dte/decoratorMetadataWithImportDeclarationNameCollision7.d.ts
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,83 @@ | ||
//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision7.ts] //// | ||
|
||
//// [db.ts] | ||
export default class db { | ||
public doSomething() { | ||
} | ||
} | ||
|
||
//// [service.ts] | ||
import db from './db'; | ||
function someDecorator(target) { | ||
return target; | ||
} | ||
@someDecorator | ||
class MyClass { | ||
db: db.db; //error | ||
|
||
constructor(db: db.db) { // error | ||
this.db = db; | ||
this.db.doSomething(); | ||
} | ||
} | ||
export {MyClass}; | ||
|
||
|
||
/// [Declarations] //// | ||
|
||
|
||
|
||
//// [db.d.ts] | ||
export default class db { | ||
doSomething(): invalid; | ||
} | ||
|
||
//// [service.d.ts] | ||
import db from './db'; | ||
declare class MyClass { | ||
db: db.db; | ||
constructor(db: db.db); | ||
} | ||
export { MyClass }; | ||
|
||
/// [Errors] //// | ||
|
||
db.ts(2,12): error TS9007: Declaration emit for this file requires type resolution. An explicit type annotation may unblock declaration emit. | ||
service.ts(7,9): error TS2702: 'db' only refers to a type, but is being used as a namespace here. | ||
service.ts(7,9): error TS4031: Public property 'db' of exported class has or is using private name 'db'. | ||
service.ts(9,21): error TS2702: 'db' only refers to a type, but is being used as a namespace here. | ||
service.ts(9,21): error TS4063: Parameter 'db' of constructor from exported class has or is using private name 'db'. | ||
|
||
|
||
==== db.ts (1 errors) ==== | ||
export default class db { | ||
public doSomething() { | ||
~~~~~~~~~~~ | ||
!!! error TS9007: Declaration emit for this file requires type resolution. An explicit type annotation may unblock declaration emit. | ||
} | ||
} | ||
|
||
==== service.ts (4 errors) ==== | ||
import db from './db'; | ||
function someDecorator(target) { | ||
return target; | ||
} | ||
@someDecorator | ||
class MyClass { | ||
db: db.db; //error | ||
~~ | ||
!!! error TS2702: 'db' only refers to a type, but is being used as a namespace here. | ||
~~ | ||
!!! error TS4031: Public property 'db' of exported class has or is using private name 'db'. | ||
|
||
constructor(db: db.db) { // error | ||
~~ | ||
!!! error TS2702: 'db' only refers to a type, but is being used as a namespace here. | ||
~~ | ||
!!! error TS4063: Parameter 'db' of constructor from exported class has or is using private name 'db'. | ||
this.db = db; | ||
this.db.doSomething(); | ||
} | ||
} | ||
export {MyClass}; | ||
|
46 changes: 46 additions & 0 deletions
46
tests/baselines/reference/isolated-declarations/original/dte/typeReferenceDirectives13.d.ts
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,46 @@ | ||
//// [tests/cases/compiler/typeReferenceDirectives13.ts] //// | ||
|
||
//// [/app.ts] | ||
/// <reference types="lib"/> | ||
import {$} from "./ref"; | ||
export interface A { | ||
x: () => typeof $ | ||
} | ||
|
||
//// [/ref.d.ts] | ||
export interface $ { x } | ||
|
||
//// [/types/lib/index.d.ts] | ||
declare let $: { x: number } | ||
|
||
|
||
/// [Declarations] //// | ||
|
||
|
||
|
||
//// [/app.d.ts] | ||
import { $ } from "./ref"; | ||
export interface A { | ||
x: () => typeof $; | ||
} | ||
|
||
/// [Errors] //// | ||
|
||
/app.ts(1,23): error TS9010: Reference directives are not supported in isolated declaration mode. | ||
|
||
|
||
==== /app.ts (1 errors) ==== | ||
/// <reference types="lib"/> | ||
~~~ | ||
!!! error TS9010: Reference directives are not supported in isolated declaration mode. | ||
import {$} from "./ref"; | ||
export interface A { | ||
x: () => typeof $ | ||
} | ||
|
||
==== /ref.d.ts (0 errors) ==== | ||
export interface $ { x } | ||
|
||
==== /types/lib/index.d.ts (0 errors) ==== | ||
declare let $: { x: number } | ||
|
44 changes: 44 additions & 0 deletions
44
tests/baselines/reference/isolated-declarations/original/dte/typeReferenceDirectives5.d.ts
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,44 @@ | ||
//// [tests/cases/compiler/typeReferenceDirectives5.ts] //// | ||
|
||
//// [/app.ts] | ||
/// <reference types="lib"/> | ||
import {$} from "./ref"; | ||
export interface A { | ||
x: typeof $; | ||
} | ||
//// [/ref.d.ts] | ||
export interface $ { x } | ||
|
||
//// [/types/lib/index.d.ts] | ||
declare let $: { x: number } | ||
|
||
|
||
/// [Declarations] //// | ||
|
||
|
||
|
||
//// [/app.d.ts] | ||
import { $ } from "./ref"; | ||
export interface A { | ||
x: typeof $; | ||
} | ||
|
||
/// [Errors] //// | ||
|
||
/app.ts(1,23): error TS9010: Reference directives are not supported in isolated declaration mode. | ||
|
||
|
||
==== /app.ts (1 errors) ==== | ||
/// <reference types="lib"/> | ||
~~~ | ||
!!! error TS9010: Reference directives are not supported in isolated declaration mode. | ||
import {$} from "./ref"; | ||
export interface A { | ||
x: typeof $; | ||
} | ||
==== /ref.d.ts (0 errors) ==== | ||
export interface $ { x } | ||
|
||
==== /types/lib/index.d.ts (0 errors) ==== | ||
declare let $: { x: number } | ||
|
82 changes: 82 additions & 0 deletions
82
...lated-declarations/original/tsc/decoratorMetadataWithImportDeclarationNameCollision7.d.ts
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,82 @@ | ||
//// [tests/cases/compiler/decoratorMetadataWithImportDeclarationNameCollision7.ts] //// | ||
|
||
//// [db.ts] | ||
export default class db { | ||
public doSomething() { | ||
} | ||
} | ||
|
||
//// [service.ts] | ||
import db from './db'; | ||
function someDecorator(target) { | ||
return target; | ||
} | ||
@someDecorator | ||
class MyClass { | ||
db: db.db; //error | ||
|
||
constructor(db: db.db) { // error | ||
this.db = db; | ||
this.db.doSomething(); | ||
} | ||
} | ||
export {MyClass}; | ||
|
||
|
||
/// [Declarations] //// | ||
|
||
|
||
|
||
//// [db.d.ts] | ||
export default class db { | ||
doSomething(): invalid; | ||
} | ||
|
||
//// [service.d.ts] | ||
declare class MyClass { | ||
db: db.db; | ||
constructor(db: db.db); | ||
} | ||
export { MyClass }; | ||
|
||
/// [Errors] //// | ||
|
||
db.ts(2,12): error TS9007: Declaration emit for this file requires type resolution. An explicit type annotation may unblock declaration emit. | ||
service.ts(7,9): error TS2702: 'db' only refers to a type, but is being used as a namespace here. | ||
service.ts(7,9): error TS4031: Public property 'db' of exported class has or is using private name 'db'. | ||
service.ts(9,21): error TS2702: 'db' only refers to a type, but is being used as a namespace here. | ||
service.ts(9,21): error TS4063: Parameter 'db' of constructor from exported class has or is using private name 'db'. | ||
|
||
|
||
==== db.ts (1 errors) ==== | ||
export default class db { | ||
public doSomething() { | ||
~~~~~~~~~~~ | ||
!!! error TS9007: Declaration emit for this file requires type resolution. An explicit type annotation may unblock declaration emit. | ||
} | ||
} | ||
|
||
==== service.ts (4 errors) ==== | ||
import db from './db'; | ||
function someDecorator(target) { | ||
return target; | ||
} | ||
@someDecorator | ||
class MyClass { | ||
db: db.db; //error | ||
~~ | ||
!!! error TS2702: 'db' only refers to a type, but is being used as a namespace here. | ||
~~ | ||
!!! error TS4031: Public property 'db' of exported class has or is using private name 'db'. | ||
|
||
constructor(db: db.db) { // error | ||
~~ | ||
!!! error TS2702: 'db' only refers to a type, but is being used as a namespace here. | ||
~~ | ||
!!! error TS4063: Parameter 'db' of constructor from exported class has or is using private name 'db'. | ||
this.db = db; | ||
this.db.doSomething(); | ||
} | ||
} | ||
export {MyClass}; | ||
|
45 changes: 45 additions & 0 deletions
45
tests/baselines/reference/isolated-declarations/original/tsc/typeReferenceDirectives13.d.ts
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,45 @@ | ||
//// [tests/cases/compiler/typeReferenceDirectives13.ts] //// | ||
|
||
//// [/app.ts] | ||
/// <reference types="lib"/> | ||
import {$} from "./ref"; | ||
export interface A { | ||
x: () => typeof $ | ||
} | ||
|
||
//// [/ref.d.ts] | ||
export interface $ { x } | ||
|
||
//// [/types/lib/index.d.ts] | ||
declare let $: { x: number } | ||
|
||
|
||
/// [Declarations] //// | ||
|
||
|
||
|
||
//// [/app.d.ts] | ||
export interface A { | ||
x: () => typeof $; | ||
} | ||
|
||
/// [Errors] //// | ||
|
||
/app.ts(1,23): error TS9010: Reference directives are not supported in isolated declaration mode. | ||
|
||
|
||
==== /app.ts (1 errors) ==== | ||
/// <reference types="lib"/> | ||
~~~ | ||
!!! error TS9010: Reference directives are not supported in isolated declaration mode. | ||
import {$} from "./ref"; | ||
export interface A { | ||
x: () => typeof $ | ||
} | ||
|
||
==== /ref.d.ts (0 errors) ==== | ||
export interface $ { x } | ||
|
||
==== /types/lib/index.d.ts (0 errors) ==== | ||
declare let $: { x: number } | ||
|
Oops, something went wrong.