-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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 issue
Milestone
Description
TypeScript Version: 3.4.0-dev.201xxxxx
Search Terms:
3.4.0 regression
parameter type infer
Code
// with compilerOptions.noImplicitAny=true in tsconfig.json
export function test<S>(options: { partial: Partial<S> | undefined }) {
const fn: any = function (state = options.partial, action_: any) {
return state
}
return fn
}The related tsconfig.json
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"noImplicitAny": true,
"noImplicitReturns": true,
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve"
},
"include": ["src"]
}Expected behavior:
No error. It's worth noting that it works in 3.3.4.
Actual behavior:
With the tsc command line, it outputs the following errors:
error TS7006: Parameter 'state' implicitly has an 'any' type.
25 const fn: any = function(state = options.partial, action_: any) {
Playground Link:
Related Issues:
The code works in 3.3.4 with no errors, but after upgrading to 3.4.0, the tsc complains that the parameter has 'any' type when the LHS fn is of any type. If I replace fn: any = with fn =, it works for 3.4.0.
jeffryang24 and timsuchanek
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 issue