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.
TypeScript Version: 3.4.0-dev.201xxxxx
Search Terms:
3.4.0 regression
parameter type infer
Code
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
tsccommand line, it outputs the following errors: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
fnis of any type. If I replacefn: any =withfn =, it works for 3.4.0.