-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Open
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureDomain: JavaScriptThe issue relates to JavaScript specificallyThe issue relates to JavaScript specificallySuggestionAn idea for TypeScriptAn idea for TypeScript
Description
› tsc --version
Version 2.7.0-dev.20171020
Code
tsconfig.json:
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"noEmit": true,
"strict": true
},
"files": [
"index.d.ts",
"index.js"
]
}
index.js:
/** @type {MyObj} */
const o = {
foo: function() {
(function() {
console.log(this); // <- Unexpected error here.
}.bind(this))();
}
};
index.d.ts:
interface MyObj {
foo(this: { a: number }): void;
}
How it looks in the editor:
But context passed to the nested function is lost:
Expected behavior:
There should not be error, because this
explicitly specified by .bind()
.
Actual behavior:
› tsc
index.js(5,25): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.
tenorok, sbmaxx, dfilatov, alt-j, saintech and 10 morexgqfrms
Metadata
Metadata
Assignees
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureDomain: JavaScriptThe issue relates to JavaScript specificallyThe issue relates to JavaScript specificallySuggestionAn idea for TypeScriptAn idea for TypeScript