-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Closed
Copy link
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issuecheckJsRelates to checking JavaScript using TypeScriptRelates to checking JavaScript using TypeScript
Milestone
Description
// ./foo.ts
class Foo {
constructor() {
this.foo = "Hello";
}
slicey() {
this.foo = this.foo.slice();
}
}
// ./tsconfig.json
{
"compilerOptions": { "strict": true },
"files": ["./foo.ts"]
}
Current Behavior
'foo' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.ts(7022)
Proposed Behavior
If an implicit any
is going to be inferred, but foo
has an initializer in the constructor, it should always infer the type from the initializer.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issuecheckJsRelates to checking JavaScript using TypeScriptRelates to checking JavaScript using TypeScript