Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Update type-only import semantics to allow type queries#36092

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
andrewbranch merged 27 commits intomicrosoft:masterfromandrewbranch:type-only-2
Jan 23, 2020
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
27 commits
Select commitHold shift + click to select a range
b40284c
Change type-only semantics to allow type queries
andrewbranchJan 8, 2020
2ae9edc
Don’t error using type-only import in ambient context
andrewbranchJan 8, 2020
db93eb2
Fix default import
andrewbranchJan 8, 2020
a2548c8
Fix namespace import
andrewbranchJan 8, 2020
8d3f167
Update more baselines
andrewbranchJan 8, 2020
b56ad7d
Prevent circular resolution
andrewbranchJan 8, 2020
0547a3d
Track const enum expression usage
andrewbranchJan 9, 2020
124dcd6
Update baselines
andrewbranchJan 9, 2020
2dd3690
Perf tuning 1
andrewbranchJan 10, 2020
eefa335
Test commit for perf impact
andrewbranchJan 10, 2020
9a24cba
Weave type-only alias declaration finding into alias resolution
andrewbranchJan 13, 2020
875349d
Fix namespace import of type-only exported symbols
andrewbranchJan 14, 2020
171e314
type-only exports do not contribute to the module object type
andrewbranchJan 14, 2020
910dd84
Update APIs
andrewbranchJan 14, 2020
2a7c472
Fix enum casing, remove type-only conversion suggestion
andrewbranchJan 14, 2020
11ba11a
Short circuit type-only checks in resolveEntityName faster
andrewbranchJan 14, 2020
0c28994
Fix casing in API
andrewbranchJan 14, 2020
40a2c3c
Remove unused parameter
andrewbranchJan 14, 2020
1cbfb81
Merge branch 'master' into type-only-2
andrewbranchJan 14, 2020
124d746
Fix error on qualified names in type queries
andrewbranchJan 14, 2020
bbbcbd5
Merge branch 'master' into type-only-2
andrewbranchJan 15, 2020
1044c5c
Allow type-only imports in computed property names
andrewbranchJan 15, 2020
a5ca492
Fix computed property names of types and abstract members
andrewbranchJan 16, 2020
8571a8a
Remove unused util
andrewbranchJan 16, 2020
8b4c235
Commit missing baselines
andrewbranchJan 16, 2020
be5f50f
Merge branch master into type-only-2
andrewbranchJan 21, 2020
19b3206
Rename “check” functions so as not to overload the word “check”
andrewbranchJan 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
PrevPrevious commit
NextNext commit
Update baselines
  • Loading branch information
@andrewbranch
andrewbranch committedJan 9, 2020
commit124dcd6937c17096082aacdc1a91320a50991fad
View file
Open in desktop
Original file line numberDiff line numberDiff 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 DownExpand 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 deletionstests/baselines/reference/importsNotUsedAsValues_error.js
View file
Open in desktop
Original file line numberDiff line numberDiff 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 DownExpand 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);
View file
Open in desktop
Original file line numberDiff line numberDiff 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 DownExpand 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 deletionstests/baselines/reference/importsNotUsedAsValues_error.types
View file
Open in desktop
Original file line numberDiff line numberDiff 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 DownExpand 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


[8]ページ先頭

©2009-2025 Movatter.jp