-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Always instantiate the extends clause, even in the presence of an error #20232
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
weswigham
merged 3 commits into
microsoft:master
from
weswigham:implicit-any-no-downstream-errors
Dec 2, 2017
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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
19 changes: 19 additions & 0 deletions
19
tests/baselines/reference/jsNoImplicitAnyNoCascadingReferenceErrors.errors.txt
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,19 @@ | ||
tests/cases/compiler/index.js(3,21): error TS8026: Expected Foo<T> type arguments; provide these with an '@extends' tag. | ||
|
||
|
||
==== tests/cases/compiler/somelib.d.ts (0 errors) ==== | ||
export declare class Foo<T> { | ||
prop: T; | ||
} | ||
==== tests/cases/compiler/index.js (1 errors) ==== | ||
import {Foo} from "./somelib"; | ||
|
||
class MyFoo extends Foo { | ||
~~~ | ||
!!! error TS8026: Expected Foo<T> type arguments; provide these with an '@extends' tag. | ||
constructor() { | ||
super(); | ||
this.prop.alpha = 12; | ||
} | ||
} | ||
|
40 changes: 40 additions & 0 deletions
40
tests/baselines/reference/jsNoImplicitAnyNoCascadingReferenceErrors.js
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,40 @@ | ||
//// [tests/cases/compiler/jsNoImplicitAnyNoCascadingReferenceErrors.ts] //// | ||
|
||
//// [somelib.d.ts] | ||
export declare class Foo<T> { | ||
prop: T; | ||
} | ||
//// [index.js] | ||
import {Foo} from "./somelib"; | ||
|
||
class MyFoo extends Foo { | ||
constructor() { | ||
super(); | ||
this.prop.alpha = 12; | ||
} | ||
} | ||
|
||
|
||
//// [index.js] | ||
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
exports.__esModule = true; | ||
var somelib_1 = require("./somelib"); | ||
var MyFoo = /** @class */ (function (_super) { | ||
__extends(MyFoo, _super); | ||
function MyFoo() { | ||
var _this = _super.call(this) || this; | ||
_this.prop.alpha = 12; | ||
return _this; | ||
} | ||
return MyFoo; | ||
}(somelib_1.Foo)); |
28 changes: 28 additions & 0 deletions
28
tests/baselines/reference/jsNoImplicitAnyNoCascadingReferenceErrors.symbols
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,28 @@ | ||
=== tests/cases/compiler/somelib.d.ts === | ||
export declare class Foo<T> { | ||
>Foo : Symbol(Foo, Decl(somelib.d.ts, --, --)) | ||
>T : Symbol(T, Decl(somelib.d.ts, --, --)) | ||
|
||
prop: T; | ||
>prop : Symbol(Foo.prop, Decl(somelib.d.ts, --, --)) | ||
>T : Symbol(T, Decl(somelib.d.ts, --, --)) | ||
} | ||
=== tests/cases/compiler/index.js === | ||
import {Foo} from "./somelib"; | ||
>Foo : Symbol(Foo, Decl(index.js, 0, 8)) | ||
|
||
class MyFoo extends Foo { | ||
>MyFoo : Symbol(MyFoo, Decl(index.js, 0, 30)) | ||
>Foo : Symbol(Foo, Decl(index.js, 0, 8)) | ||
|
||
constructor() { | ||
super(); | ||
>super : Symbol(Foo, Decl(somelib.d.ts, --, --)) | ||
|
||
this.prop.alpha = 12; | ||
>this.prop : Symbol(Foo.prop, Decl(somelib.d.ts, --, --)) | ||
>this : Symbol(MyFoo, Decl(index.js, 0, 30)) | ||
>prop : Symbol(Foo.prop, Decl(somelib.d.ts, --, --)) | ||
} | ||
} | ||
|
33 changes: 33 additions & 0 deletions
33
tests/baselines/reference/jsNoImplicitAnyNoCascadingReferenceErrors.types
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,33 @@ | ||
=== tests/cases/compiler/somelib.d.ts === | ||
export declare class Foo<T> { | ||
>Foo : Foo<T> | ||
>T : T | ||
|
||
prop: T; | ||
>prop : T | ||
>T : T | ||
} | ||
=== tests/cases/compiler/index.js === | ||
import {Foo} from "./somelib"; | ||
>Foo : typeof Foo | ||
|
||
class MyFoo extends Foo { | ||
>MyFoo : MyFoo | ||
>Foo : Foo<any> | ||
|
||
constructor() { | ||
super(); | ||
>super() : void | ||
>super : typeof Foo | ||
|
||
this.prop.alpha = 12; | ||
>this.prop.alpha = 12 : 12 | ||
>this.prop.alpha : any | ||
>this.prop : any | ||
>this : this | ||
>prop : any | ||
>alpha : any | ||
>12 : 12 | ||
} | ||
} | ||
|
17 changes: 17 additions & 0 deletions
17
tests/cases/compiler/jsNoImplicitAnyNoCascadingReferenceErrors.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,17 @@ | ||
// @allowJs: true | ||
// @checkJs: true | ||
// @noImplicitAny: true | ||
// @outDir: ./built | ||
// @filename: somelib.d.ts | ||
export declare class Foo<T> { | ||
prop: T; | ||
} | ||
// @filename: index.js | ||
import {Foo} from "./somelib"; | ||
|
||
class MyFoo extends Foo { | ||
constructor() { | ||
super(); | ||
this.prop.alpha = 12; | ||
} | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so what broke with the permissive behavior in TS?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing is "broken" once all the arity-based signature removals are excised and arity verification is moved into
fillMissingTypeArguments
- just observable behavior changes to follow-on error scenarios (which cause a bunch of baseline churn - and in TS it is not uniformly better behavior, since we fill with{}
instead ofany
- we could change that if there's an arity mismatch); I'll open a PR on my PR to show you, here: weswigham#2I can merge it into this PR and iterate on it if you think it's a good idea (or do a second PR after this one). I just didn't want to add it in (it is more complicated, but also likely more complete) without mentioning it to someone first. It just amounts to better error recovery, so even if it does change a bunch of
any
's to more specific types in the baselines (as expected), I don't think it'd even be a breaking change, actually....That did take longer than I expected to fully flesh out, though - partially because I had to work around our inconsistent handling of generics on psuedoconstructors (like
ArrayConstructor
). Namely you can write:and those ctor return types are in no way compatable, but we don't issue an error because we don't look at the different arities' signatures simultaneously right now. It's the reason for all the complexity around
getInstantiatedConstructorsForTypeArguments
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the clarification. i think i understand now. i am not sure i understand the change in weswigham#2, but we should talk about that one on Monday.