This repository was archived by the owner on Jan 19, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 75
Update: add proper scope analysis (fixes #535) #540
Merged
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
4e83b52
Update: add proper scope analysis (fixes #535)
mysticatea 1cfbb6e
add computed-properties-in-type fixture
mysticatea 1ec6b3a
add computed-properties-in-interface fixture
mysticatea 80b13cf
add function-overload fixture
mysticatea 3d7cfb2
add method-overload fixture
mysticatea f61e133
add class-properties fixture
mysticatea bdd99e9
add decorators fixture
mysticatea f908e81
update visitor-keys
mysticatea 00ce3dc
add declare-global fixture
mysticatea bbf0b69
fix typo
mysticatea 257e953
add test for typeof in array destructuring
mysticatea 85b9067
add namespace fixture
mysticatea 7a8e250
add declare-module fixture
mysticatea 8a9eb40
fix crash
mysticatea 5e3b3f6
add declare-function.ts fixture
mysticatea efeda57
add abstract-class fixture
mysticatea f5de9b0
add typeof-in-call-signature fixture
mysticatea 7ce5d61
add test for #416
mysticatea ca4b08f
add test for #435
mysticatea 72f7120
add test for #437
mysticatea b8b86fd
add test for #443
mysticatea 49ce2da
add test for #459
mysticatea 13f50c3
add test for #466
mysticatea 180cbfe
add test for #471
mysticatea 6e70971
add test for #487
mysticatea 81f4f30
add test for #535
mysticatea 95a8380
add test for #536
mysticatea 14e2499
Merge remote-tracking branch 'origin/master' into fix-scope-analysis
mysticatea 044563b
add test for #476
mysticatea 2a5669d
fix test to use `expect()`
mysticatea b79045e
Merge remote-tracking branch 'origin/master' into fix-scope-analysis
mysticatea File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,3 @@ | ||
function foo({ bar }: { bar: string }) { | ||
bar; | ||
} |
This file contains hidden or 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,4 @@ | ||
abstract class A { | ||
abstract a: string | ||
abstract f(): number | ||
} |
This file contains hidden or 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,5 @@ | ||
const s = Symbol() | ||
class A { | ||
a: typeof s | ||
[s]: number | ||
} |
5 changes: 5 additions & 0 deletions
5
tests/fixtures/scope-analysis/computed-properties-in-interface.ts
This file contains hidden or 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,5 @@ | ||
const s1 = Symbol(), s2 = Symbol() | ||
interface A { | ||
[s1]: number | ||
[s2](s1: number, s2: number): number; | ||
} |
This file contains hidden or 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,5 @@ | ||
const s1 = Symbol(), s2 = Symbol() | ||
type A = { | ||
[s1]: number | ||
[s2](s1: number, s2: number): number; | ||
} |
This file contains hidden or 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,2 @@ | ||
declare function f(a: number): number | ||
f |
This file contains hidden or 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,7 @@ | ||
declare global { | ||
let C: number | ||
} | ||
|
||
C = 1 | ||
|
||
export {} |
This file contains hidden or 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,6 @@ | ||
const a = 1 | ||
declare module "foo" { | ||
export const a: number | ||
export const b: typeof a | ||
} | ||
a |
This file contains hidden or 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,13 @@ | ||
function dec(target: any) { | ||
} | ||
function gec() { | ||
return (target: any, propertyKey: string) => {} | ||
} | ||
|
||
@dec | ||
class C { | ||
@gec() field: string | ||
@gec() method(): string { | ||
return "" | ||
} | ||
} |
This file contains hidden or 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,6 @@ | ||
const a: number = 1 | ||
enum E { | ||
A = a, | ||
B = a + 1, | ||
C = A + B | ||
} |
This file contains hidden or 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,2 @@ | ||
function f(): void | ||
function f(a: number): void |
This file contains hidden or 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,5 @@ | ||
function f(): void | ||
function f(a: number): void | ||
function f(a?: number): void { | ||
// do something. | ||
} |
This file contains hidden or 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,9 @@ | ||
type A = number | ||
interface B { | ||
prop1: A | ||
} | ||
interface C extends B { | ||
method(a: { b: A }): { c: A } | ||
} | ||
|
||
var a: C |
This file contains hidden or 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,8 @@ | ||
const s = Symbol() | ||
class A { | ||
f(): void | ||
f(a: typeof s): void | ||
f(a?: any): void { | ||
// do something. | ||
} | ||
} |
This file contains hidden or 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,7 @@ | ||
const a = 1 | ||
namespace N { | ||
export const a = 2 | ||
a | ||
} | ||
a | ||
N.a |
This file contains hidden or 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,7 @@ | ||
type A = number | ||
var a: { b: A } | ||
class C { | ||
f(a: { b: A }): { b: A } { | ||
return {b: 1} | ||
} | ||
} |
This file contains hidden or 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,3 @@ | ||
type A = number; | ||
a = <A> b; | ||
a = b as A; |
This file contains hidden or 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,3 @@ | ||
var obj = { value: 1 } | ||
a = <typeof obj>b; | ||
a = b as typeof obj; |
This file contains hidden or 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,5 @@ | ||
const obj = { value: 1 } | ||
interface A { | ||
<T extends typeof obj>(a: typeof obj, b: T): typeof obj | ||
new <T extends typeof obj>(a: typeof obj, b: T): typeof obj | ||
} |
This file contains hidden or 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,3 @@ | ||
function f(a: number): typeof a { // this `a` is the parameter `a`. | ||
return 1 | ||
} |
This file contains hidden or 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,3 @@ | ||
function g<T extends typeof g>(g: T): number { | ||
return 1 | ||
} |
This file contains hidden or 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,4 @@ | ||
var obj = { value: 1 } | ||
var obj2: typeof obj = { value: 2 } | ||
var { value }: typeof obj = { value: 2 } | ||
mysticatea marked this conversation as resolved.
Show resolved
Hide resolved
|
||
var [element]: (typeof obj)[] = [{ value: 2 }] |
This file contains hidden or 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,2 @@ | ||
var obj = { value: 1 } | ||
type B = typeof obj |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.