Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
174 changes: 115 additions & 59 deletions src/compiler/checker.ts

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4934,6 +4934,7 @@ namespace ts {
HasNeverType = 1 << 17, // Synthetic property with at least one never type in constituents
Mapped = 1 << 18, // Property of mapped type
StripOptional = 1 << 19, // Strip optionality in mapped property
Unresolved = 1 << 20, // Unresolved type alias symbol
Synthetic = SyntheticProperty | SyntheticMethod,
Discriminant = HasNonUniformType | HasLiteralType,
Partial = ReadPartial | WritePartial
Expand Down
1 change: 1 addition & 0 deletions tests/baselines/reference/ArrowFunction1.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
var v = (a: ) => {
>v : Symbol(v, Decl(ArrowFunction1.ts, 0, 3))
>a : Symbol(a, Decl(ArrowFunction1.ts, 0, 9))
> : Symbol(unknown)

};
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module clodule1 {
function f(x: T) { }
>f : Symbol(f, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 8, 17))
>x : Symbol(x, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 9, 15))
>T : Symbol(T)
}

class clodule2<T>{
Expand All @@ -38,10 +39,12 @@ module clodule2 {

var x: T;
>x : Symbol(x, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 19, 7))
>T : Symbol(T)

class D<U extends T>{
>D : Symbol(D, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 19, 13))
>U : Symbol(U, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 21, 12))
>T : Symbol(T)

id: string;
>id : Symbol(D.id, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 21, 25))
Expand Down Expand Up @@ -92,6 +95,7 @@ module clodule4 {

name: T;
>name : Symbol(D.name, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 44, 13))
>T : Symbol(T)
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ module clodule1 {
>clodule1 : typeof clodule1

function f(x: T) { }
>f : (x: any) => void
>x : any
>f : (x: T) => void
>x : T
}

class clodule2<T>{
Expand All @@ -33,7 +33,7 @@ module clodule2 {
>clodule2 : typeof clodule2

var x: T;
>x : any
>x : T

class D<U extends T>{
>D : D<U>
Expand Down Expand Up @@ -83,7 +83,7 @@ module clodule4 {
>D : D

name: T;
>name : any
>name : T
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ function * foo() {
// Legal to use 'yield' in a type context.
var v: yield;
>v : Symbol(v, Decl(FunctionDeclaration13_es6.ts, 2, 6))
>yield : Symbol(yield)
}

2 changes: 1 addition & 1 deletion tests/baselines/reference/FunctionDeclaration13_es6.types
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ function * foo() {

// Legal to use 'yield' in a type context.
var v: yield;
>v : any
>v : yield
}

1 change: 1 addition & 0 deletions tests/baselines/reference/ParameterList5.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
function A(): (public B) => C {
>A : Symbol(A, Decl(ParameterList5.ts, 0, 0))
>B : Symbol(B, Decl(ParameterList5.ts, 0, 15))
>C : Symbol(C)
}
2 changes: 1 addition & 1 deletion tests/baselines/reference/ParameterList5.types
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
=== tests/cases/compiler/ParameterList5.ts ===
function A(): (public B) => C {
>A : () => (B: any) => any
>A : () => (B: any) => C
>B : any
}
1 change: 1 addition & 0 deletions tests/baselines/reference/TupleType6.symbols
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
=== tests/cases/conformance/parser/ecmascript5/TupleTypes/TupleType6.ts ===
var v: [number,,]
>v : Symbol(v, Decl(TupleType6.ts, 0, 3))
> : Symbol(unknown)

Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export module A {
// collision with 'Origin' var in other part of merged module
export var Origin: Point = { x: 0, y: 0 };
>Origin : Symbol(Origin, Decl(part2.ts, 2, 14))
>Point : Symbol(Point)
>x : Symbol(x, Decl(part2.ts, 2, 32))
>y : Symbol(y, Decl(part2.ts, 2, 38))

Expand All @@ -59,7 +60,9 @@ export module A {

constructor(public tl: Point, public br: Point) { }
>tl : Symbol(Plane.tl, Decl(part2.ts, 6, 24))
>Point : Symbol(Point)
>br : Symbol(Plane.br, Decl(part2.ts, 6, 41))
>Point : Symbol(Point)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export module A {

// collision with 'Origin' var in other part of merged module
export var Origin: Point = { x: 0, y: 0 };
>Origin : any
>Origin : Point
>{ x: 0, y: 0 } : { x: number; y: number; }
>x : number
>0 : 0
Expand All @@ -59,8 +59,8 @@ export module A {
>Plane : Plane

constructor(public tl: Point, public br: Point) { }
>tl : any
>br : any
>tl : Point
>br : Point
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export class Q {
set bet(arg: DoesNotExist) {}
>bet : Symbol(Q.bet, Decl(accessorDeclarationEmitVisibilityErrors.ts, 0, 16))
>arg : Symbol(arg, Decl(accessorDeclarationEmitVisibilityErrors.ts, 1, 12))
>DoesNotExist : Symbol(DoesNotExist)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ export class Q {
>Q : Q

set bet(arg: DoesNotExist) {}
>bet : any
>arg : any
>bet : DoesNotExist
>arg : DoesNotExist
}
1 change: 1 addition & 0 deletions tests/baselines/reference/aliasBug.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ function use() {
var p3:booz.bar;
>p3 : Symbol(p3, Decl(aliasBug.ts, 15, 5))
>booz : Symbol(booz, Decl(aliasBug.ts, 7, 21))
>bar : Symbol(booz.bar)

var p22 = new provide.Provide();
>p22 : Symbol(p22, Decl(aliasBug.ts, 16, 5))
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/aliasBug.types
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function use() {
>foo : any

var p3:booz.bar;
>p3 : any
>p3 : booz.bar
>booz : any

var p22 = new provide.Provide();
Expand Down
1 change: 1 addition & 0 deletions tests/baselines/reference/aliasErrors.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ function use() {
var p3:booz.bar;
>p3 : Symbol(p3, Decl(aliasErrors.ts, 25, 5))
>booz : Symbol(booz, Decl(aliasErrors.ts, 6, 21))
>bar : Symbol(booz.bar)

var p22 = new provide.Provide();
>p22 : Symbol(p22, Decl(aliasErrors.ts, 26, 5))
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/aliasErrors.types
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function use() {
>foo : any

var p3:booz.bar;
>p3 : any
>p3 : booz.bar
>booz : any

var p22 = new provide.Provide();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ originalZZZ;

const y: originalZZZ = x;
>y : Symbol(y, Decl(index.ts, 8, 5))
>originalZZZ : Symbol(originalZZZ)
>x : Symbol(x, Decl(index.ts, 2, 5))

Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ originalZZZ;
>originalZZZ : 123

const y: originalZZZ = x;
>y : any
>y : originalZZZ
>x : zzz

Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ assertEqual(animal.type, 'cat' as const);
>animal.type : Symbol(type, Decl(assertionFunctionsCanNarrowByDiscriminant.ts, 0, 15), Decl(assertionFunctionsCanNarrowByDiscriminant.ts, 5, 15))
>animal : Symbol(animal, Decl(assertionFunctionsCanNarrowByDiscriminant.ts, 14, 5))
>type : Symbol(type, Decl(assertionFunctionsCanNarrowByDiscriminant.ts, 0, 15), Decl(assertionFunctionsCanNarrowByDiscriminant.ts, 5, 15))
>const : Symbol(const)

animal.canMeow; // since is cat, should not be an error
>animal.canMeow : Symbol(Cat.canMeow, Decl(assertionFunctionsCanNarrowByDiscriminant.ts, 1, 16))
Expand All @@ -61,6 +62,7 @@ assertEqual(animalOrUndef?.type, 'cat' as const);
>animalOrUndef?.type : Symbol(type, Decl(assertionFunctionsCanNarrowByDiscriminant.ts, 0, 15), Decl(assertionFunctionsCanNarrowByDiscriminant.ts, 5, 15))
>animalOrUndef : Symbol(animalOrUndef, Decl(assertionFunctionsCanNarrowByDiscriminant.ts, 19, 5))
>type : Symbol(type, Decl(assertionFunctionsCanNarrowByDiscriminant.ts, 0, 15), Decl(assertionFunctionsCanNarrowByDiscriminant.ts, 5, 15))
>const : Symbol(const)

animalOrUndef.canMeow; // since is cat, should not be an error
>animalOrUndef.canMeow : Symbol(Cat.canMeow, Decl(assertionFunctionsCanNarrowByDiscriminant.ts, 1, 16))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface Derived2 extends Derived { baz: string; }

var a: A;
>a : Symbol(a, Decl(assignmentCompatWithStringIndexer3.ts, 6, 3))
>A : Symbol(A)

var b1: { [x: string]: string; }
>b1 : Symbol(b1, Decl(assignmentCompatWithStringIndexer3.ts, 7, 3))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ interface Derived2 extends Derived { baz: string; }
>baz : string

var a: A;
>a : any
>a : A

var b1: { [x: string]: string; }
>b1 : { [x: string]: string; }
>x : string

a = b1; // error
>a = b1 : { [x: string]: string; }
>a : any
>a : A
>b1 : { [x: string]: string; }

b1 = a; // error
>b1 = a : any
>b1 = a : A
>b1 : { [x: string]: string; }
>a : any
>a : A

module Generics {
>Generics : typeof Generics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ var foo = async (): Promise<void> => {
// Legal to use 'await' in a type context.
var v: await;
>v : Symbol(v, Decl(asyncArrowFunction10_es2017.ts, 2, 6))
>await : Symbol(await)
}

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ var foo = async (): Promise<void> => {

// Legal to use 'await' in a type context.
var v: await;
>v : any
>v : await
}

1 change: 1 addition & 0 deletions tests/baselines/reference/asyncArrowFunction10_es5.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ var foo = async (): Promise<void> => {
// Legal to use 'await' in a type context.
var v: await;
>v : Symbol(v, Decl(asyncArrowFunction10_es5.ts, 2, 6))
>await : Symbol(await)
}

2 changes: 1 addition & 1 deletion tests/baselines/reference/asyncArrowFunction10_es5.types
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ var foo = async (): Promise<void> => {

// Legal to use 'await' in a type context.
var v: await;
>v : any
>v : await
}

1 change: 1 addition & 0 deletions tests/baselines/reference/asyncArrowFunction10_es6.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ var foo = async (): Promise<void> => {
// Legal to use 'await' in a type context.
var v: await;
>v : Symbol(v, Decl(asyncArrowFunction10_es6.ts, 2, 6))
>await : Symbol(await)
}

2 changes: 1 addition & 1 deletion tests/baselines/reference/asyncArrowFunction10_es6.types
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ var foo = async (): Promise<void> => {

// Legal to use 'await' in a type context.
var v: await;
>v : any
>v : await
}

Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ async function foo(): Promise<void> {
// Legal to use 'await' in a type context.
var v: await;
>v : Symbol(v, Decl(asyncFunctionDeclaration13_es2017.ts, 2, 6))
>await : Symbol(await)
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ async function foo(): Promise<void> {

// Legal to use 'await' in a type context.
var v: await;
>v : any
>v : await
}

Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ async function foo(): Promise<void> {
// Legal to use 'await' in a type context.
var v: await;
>v : Symbol(v, Decl(asyncFunctionDeclaration13_es5.ts, 2, 6))
>await : Symbol(await)
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ async function foo(): Promise<void> {

// Legal to use 'await' in a type context.
var v: await;
>v : any
>v : await
}

Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ async function foo(): Promise<void> {
// Legal to use 'await' in a type context.
var v: await;
>v : Symbol(v, Decl(asyncFunctionDeclaration13_es6.ts, 2, 6))
>await : Symbol(await)
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ async function foo(): Promise<void> {

// Legal to use 'await' in a type context.
var v: await;
>v : any
>v : await
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some way to make the type writer a little smarter here so that the team can differentiate between an unresolved and a concrete type?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We certainly have the ability to tell the difference, but what did you have in mind in terms of output? Remember that we're often dealing with composed types, e.g. for var v: Promise<await[]> we can't easily attach a comment to the await identifier in the output.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A parenthesized type might work like (/*unresolved*/ await)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure we want to do that. We're already generate an error at every reference to an unresolved symbol, I don't think we also want the extra noise in the type baselines.

}

2 changes: 2 additions & 0 deletions tests/baselines/reference/augmentExportEquals1.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import x = require("./file1");
import "./file2";
let a: x.A; // should not work
>a : Symbol(a, Decl(file3.ts, 2, 3))
>x : Symbol(x)
>A : Symbol(x.A)

=== tests/cases/compiler/file1.ts ===
var x = 1;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/augmentExportEquals1.types
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import x = require("./file1");

import "./file2";
let a: x.A; // should not work
>a : any
>a : x.A
>x : any

=== tests/cases/compiler/file1.ts ===
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/augmentExportEquals1_1.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import x = require("file1");
import "file2";
let a: x.A; // should not work
>a : Symbol(a, Decl(file3.ts, 2, 3))
>x : Symbol(x)
>A : Symbol(x.A)

=== tests/cases/compiler/file1.d.ts ===
declare module "file1" {
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/augmentExportEquals1_1.types
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import x = require("file1");

import "file2";
let a: x.A; // should not work
>a : any
>a : x.A
>x : any

=== tests/cases/compiler/file1.d.ts ===
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/augmentExportEquals2.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import x = require("./file1");
import "./file2";
let a: x.A; // should not work
>a : Symbol(a, Decl(file3.ts, 2, 3))
>x : Symbol(x)
>A : Symbol(x.A)

=== tests/cases/compiler/file1.ts ===
function foo() {}
Expand Down
Loading