Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b40284c
Change type-only semantics to allow type queries
andrewbranch Jan 8, 2020
2ae9edc
Don’t error using type-only import in ambient context
andrewbranch Jan 8, 2020
db93eb2
Fix default import
andrewbranch Jan 8, 2020
a2548c8
Fix namespace import
andrewbranch Jan 8, 2020
8d3f167
Update more baselines
andrewbranch Jan 8, 2020
b56ad7d
Prevent circular resolution
andrewbranch Jan 8, 2020
0547a3d
Track const enum expression usage
andrewbranch Jan 9, 2020
124dcd6
Update baselines
andrewbranch Jan 9, 2020
2dd3690
Perf tuning 1
andrewbranch Jan 10, 2020
eefa335
Test commit for perf impact
andrewbranch Jan 10, 2020
9a24cba
Weave type-only alias declaration finding into alias resolution
andrewbranch Jan 13, 2020
875349d
Fix namespace import of type-only exported symbols
andrewbranch Jan 14, 2020
171e314
type-only exports do not contribute to the module object type
andrewbranch Jan 14, 2020
910dd84
Update APIs
andrewbranch Jan 14, 2020
2a7c472
Fix enum casing, remove type-only conversion suggestion
andrewbranch Jan 14, 2020
11ba11a
Short circuit type-only checks in resolveEntityName faster
andrewbranch Jan 14, 2020
0c28994
Fix casing in API
andrewbranch Jan 14, 2020
40a2c3c
Remove unused parameter
andrewbranch Jan 14, 2020
1cbfb81
Merge branch 'master' into type-only-2
andrewbranch Jan 14, 2020
124d746
Fix error on qualified names in type queries
andrewbranch Jan 14, 2020
bbbcbd5
Merge branch 'master' into type-only-2
andrewbranch Jan 15, 2020
1044c5c
Allow type-only imports in computed property names
andrewbranch Jan 15, 2020
a5ca492
Fix computed property names of types and abstract members
andrewbranch Jan 16, 2020
8571a8a
Remove unused util
andrewbranch Jan 16, 2020
8b4c235
Commit missing baselines
andrewbranch Jan 16, 2020
be5f50f
Merge branch master into type-only-2
andrewbranch Jan 21, 2020
19b3206
Rename “check” functions so as not to overload the word “check”
andrewbranch Jan 23, 2020
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
Prev Previous commit
Next Next commit
Update baselines
  • Loading branch information
andrewbranch committed Jan 9, 2020
commit 124dcd6937c17096082aacdc1a91320a50991fad
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/b.ts(1,1): error TS1371: This import is never used as a value and must use 'import type' because the 'importsNotUsedAsValues' is set to 'error'.
/c.ts(1,1): error TS1371: This import is never used as a value and must use 'import type' because the 'importsNotUsedAsValues' is set to 'error'.
/e.ts(1,1): error TS6192: All imports in import declaration are unused.
/g.ts(1,1): error TS1371: This import is never used as a value and must use 'import type' because the 'importsNotUsedAsValues' is set to 'error'.


==== /a.ts (0 errors) ====
export default class {}
export class A {}
export type B = {};
export const enum C { One, Two }

==== /b.ts (1 errors) ====
import { A, B } from './a'; // Error
Expand Down Expand Up @@ -34,4 +36,19 @@
import { A, B } from './a'; // noUnusedLocals error only
~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS6192: All imports in import declaration are unused.


==== /f.ts (0 errors) ====
import { C } from './a';
import type { C as D } from './a';
C.One;
let c: D = C.Two;
let d: D.Two = C.Two;
console.log(c, d);

==== /g.ts (1 errors) ====
import { C } from './a';
~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1371: This import is never used as a value and must use 'import type' because the 'importsNotUsedAsValues' is set to 'error'.
let c: C;
let d: C.Two;
console.log(c, d);
29 changes: 29 additions & 0 deletions tests/baselines/reference/importsNotUsedAsValues_error.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
export default class {}
export class A {}
export type B = {};
export const enum C { One, Two }

//// [b.ts]
import { A, B } from './a'; // Error
Expand All @@ -26,6 +27,19 @@ console.log(a, b);
//// [e.ts]
import { A, B } from './a'; // noUnusedLocals error only

//// [f.ts]
import { C } from './a';
import type { C as D } from './a';
C.One;
let c: D = C.Two;
let d: D.Two = C.Two;
console.log(c, d);

//// [g.ts]
import { C } from './a';
let c: C;
let d: C.Two;
console.log(c, d);

//// [a.js]
"use strict";
Expand Down Expand Up @@ -67,3 +81,18 @@ console.log(a, b);
"use strict";
exports.__esModule = true;
require("./a"); // noUnusedLocals error only
//// [f.js]
"use strict";
exports.__esModule = true;
require("./a");
0 /* One */;
var c = 1 /* Two */;
var d = 1 /* Two */;
console.log(c, d);
//// [g.js]
"use strict";
exports.__esModule = true;
require("./a");
var c;
var d;
console.log(c, d);
60 changes: 60 additions & 0 deletions tests/baselines/reference/importsNotUsedAsValues_error.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ export class A {}
export type B = {};
>B : Symbol(B, Decl(a.ts, 1, 17))

export const enum C { One, Two }
>C : Symbol(C, Decl(a.ts, 2, 19))
>One : Symbol(C.One, Decl(a.ts, 3, 21))
>Two : Symbol(C.Two, Decl(a.ts, 3, 26))

=== /b.ts ===
import { A, B } from './a'; // Error
>A : Symbol(A, Decl(b.ts, 0, 8))
Expand Down Expand Up @@ -72,3 +77,58 @@ import { A, B } from './a'; // noUnusedLocals error only
>A : Symbol(A, Decl(e.ts, 0, 8))
>B : Symbol(B, Decl(e.ts, 0, 11))

=== /f.ts ===
import { C } from './a';
>C : Symbol(C, Decl(f.ts, 0, 8))

import type { C as D } from './a';
>C : Symbol(C, Decl(a.ts, 2, 19))
>D : Symbol(D, Decl(f.ts, 1, 13))

C.One;
>C.One : Symbol(C.One, Decl(a.ts, 3, 21))
>C : Symbol(C, Decl(f.ts, 0, 8))
>One : Symbol(C.One, Decl(a.ts, 3, 21))

let c: D = C.Two;
>c : Symbol(c, Decl(f.ts, 3, 3))
>D : Symbol(D, Decl(f.ts, 1, 13))
>C.Two : Symbol(C.Two, Decl(a.ts, 3, 26))
>C : Symbol(C, Decl(f.ts, 0, 8))
>Two : Symbol(C.Two, Decl(a.ts, 3, 26))

let d: D.Two = C.Two;
>d : Symbol(d, Decl(f.ts, 4, 3))
>D : Symbol(D, Decl(f.ts, 1, 13))
>Two : Symbol(C.Two, Decl(a.ts, 3, 26))
>C.Two : Symbol(C.Two, Decl(a.ts, 3, 26))
>C : Symbol(C, Decl(f.ts, 0, 8))
>Two : Symbol(C.Two, Decl(a.ts, 3, 26))

console.log(c, d);
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>c : Symbol(c, Decl(f.ts, 3, 3))
>d : Symbol(d, Decl(f.ts, 4, 3))

=== /g.ts ===
import { C } from './a';
>C : Symbol(C, Decl(g.ts, 0, 8))

let c: C;
>c : Symbol(c, Decl(g.ts, 1, 3))
>C : Symbol(C, Decl(g.ts, 0, 8))

let d: C.Two;
>d : Symbol(d, Decl(g.ts, 2, 3))
>C : Symbol(C, Decl(g.ts, 0, 8))
>Two : Symbol(C.Two, Decl(a.ts, 3, 26))

console.log(c, d);
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
>c : Symbol(c, Decl(g.ts, 1, 3))
>d : Symbol(d, Decl(g.ts, 2, 3))

58 changes: 58 additions & 0 deletions tests/baselines/reference/importsNotUsedAsValues_error.types
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ export class A {}
export type B = {};
>B : B

export const enum C { One, Two }
>C : C
>One : C.One
>Two : C.Two

=== /b.ts ===
import { A, B } from './a'; // Error
>A : typeof A
Expand Down Expand Up @@ -70,3 +75,56 @@ import { A, B } from './a'; // noUnusedLocals error only
>A : typeof A
>B : any

=== /f.ts ===
import { C } from './a';
>C : typeof C

import type { C as D } from './a';
>C : typeof C
>D : C

C.One;
>C.One : C.One
>C : typeof C
>One : C.One

let c: D = C.Two;
>c : C
>C.Two : C.Two
>C : typeof C
>Two : C.Two

let d: D.Two = C.Two;
>d : C.Two
>D : any
>C.Two : C.Two
>C : typeof C
>Two : C.Two

console.log(c, d);
>console.log(c, d) : void
>console.log : (message?: any, ...optionalParams: any[]) => void
>console : Console
>log : (message?: any, ...optionalParams: any[]) => void
>c : C.Two
>d : C.Two

=== /g.ts ===
import { C } from './a';
>C : typeof C

let c: C;
>c : C

let d: C.Two;
>d : C.Two
>C : any

console.log(c, d);
>console.log(c, d) : void
>console.log : (message?: any, ...optionalParams: any[]) => void
>console : Console
>log : (message?: any, ...optionalParams: any[]) => void
>c : C
>d : C.Two