From 62ac2944601dde3db6a6899840de3fe0aaf4ce85 Mon Sep 17 00:00:00 2001 From: Jack Bates Date: Wed, 28 Aug 2019 16:18:51 -0700 Subject: [PATCH] Higher order this parameter inference, like #31116 --- src/compiler/checker.ts | 2 +- tests/baselines/reference/user/create-react-app.log | 2 +- tests/baselines/reference/user/npm.log | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 85c6b695063d7..0d96cb326a128 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -23725,7 +23725,7 @@ namespace ts { const thisType = getThisTypeOfSignature(signature); if (thisType) { const thisArgumentNode = getThisArgumentOfCall(node); - const thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; + const thisArgumentType = thisArgumentNode ? checkExpressionWithContextualType(thisArgumentNode, thisType, context, checkMode) : voidType; inferTypes(context.inferences, thisArgumentType, thisType); } diff --git a/tests/baselines/reference/user/create-react-app.log b/tests/baselines/reference/user/create-react-app.log index 4ce65c3b59abe..d2ccce82e6a10 100644 --- a/tests/baselines/reference/user/create-react-app.log +++ b/tests/baselines/reference/user/create-react-app.log @@ -1,6 +1,6 @@ Exit Code: 1 Standard output: -test/fixtures/issue-5176-flow-class-properties/src/App.js(5,8): error TS8010: 'types' can only be used in a .ts file. +test/fixtures/issue-5176-flow-class-properties/src/App.js(5,8): error TS8010: Type annotations can only be used in TypeScript files. test/fixtures/issue-5176-flow-class-properties/src/App.js(5,13): error TS1005: ';' expected. test/fixtures/webpack-message-formatting/src/AppBabel.js(6,8): error TS17008: JSX element 'div' has no corresponding closing tag. test/fixtures/webpack-message-formatting/src/AppBabel.js(8,7): error TS17002: Expected corresponding JSX closing tag for 'span'. diff --git a/tests/baselines/reference/user/npm.log b/tests/baselines/reference/user/npm.log index 4acc7e58cafd7..edbad98f256c8 100644 --- a/tests/baselines/reference/user/npm.log +++ b/tests/baselines/reference/user/npm.log @@ -925,6 +925,14 @@ node_modules/npm/lib/whoami.js(18,18): error TS2339: Property 'config' does not node_modules/npm/lib/whoami.js(24,18): error TS2339: Property 'registry' does not exist on type 'typeof EventEmitter'. node_modules/npm/lib/whoami.js(30,26): error TS2339: Property 'code' does not exist on type 'Error'. node_modules/npm/lib/whoami.js(45,12): error TS2339: Property 'code' does not exist on type 'Error'. +node_modules/npm/scripts/index-build.js(20,13): error TS2531: Object is possibly 'null'. +node_modules/npm/scripts/index-build.js(20,22): error TS2531: Object is possibly 'null'. +node_modules/npm/scripts/index-build.js(21,30): error TS2531: Object is possibly 'null'. +node_modules/npm/scripts/index-build.js(22,29): error TS2531: Object is possibly 'null'. +node_modules/npm/scripts/index-build.js(23,15): error TS2531: Object is possibly 'null'. +node_modules/npm/scripts/index-build.js(23,22): error TS2531: Object is possibly 'null'. +node_modules/npm/scripts/index-build.js(24,15): error TS2531: Object is possibly 'null'. +node_modules/npm/scripts/index-build.js(24,22): error TS2531: Object is possibly 'null'. node_modules/npm/scripts/publish-tag.js(2,36): error TS2732: Cannot find module '../package.json'. Consider using '--resolveJsonModule' to import module with '.json' extension node_modules/npm/test/broken-under-nyc-and-travis/lifecycle-path.js(7,20): error TS2307: Cannot find module 'tap'. node_modules/npm/test/broken-under-nyc-and-travis/lifecycle-path.js(18,23): error TS2345: Argument of type 'string | undefined' is not assignable to parameter of type 'string'.