TypeScript Versions: from 3.5.1 to Nightly (issue not present in 3.3.3)
Search Terms:array map
Expected behavior: Third assignment should raise an error
Actual behavior: Assignment is allowed
Related Issues: No found any
Code
interfaceA{a: 2}// 1. Correct: b property is not allowed in type Aconsta: A={a: 2,b: 8}// 2. Correct: b property is not allowed in type Aconstother: A[]=[{a: 2,b: 8}]// 3. Incorrect (no error): why is b property permitted here?constarray: A[]=[1,2].map(i=>({a: 2,b: 8}))Output
"use strict";// 1. Correct: b property is not allowed in type Aconsta={a: 2,b: 8};// 2. Correct: b property is not allowed in type Aconstother=[{a: 2,b: 8}];// 3. Incorrect (no error): why is b property permitted here?constarray=[1,2].map(i=>({a: 2,b: 8}));Compiler Options
{
"compilerOptions": {
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"strictBindCallApply": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"useDefineForClassFields": false,
"alwaysStrict": true,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"downlevelIteration": false,
"noEmitHelpers": false,
"noLib": false,
"noStrictGenericChecks": false,
"noUnusedLocals": false,
"noUnusedParameters": false,
"esModuleInterop": true,
"preserveConstEnums": false,
"removeComments": false,
"skipLibCheck": false,
"checkJs": false,
"allowJs": false,
"declaration": true,
"experimentalDecorators": false,
"emitDecoratorMetadata": false,
"target": "ES2017",
"module": "ESNext"
}
}Playground Link:Provided
TypeScript Versions: from 3.5.1 to Nightly (issue not present in 3.3.3)
Search Terms:
array mapExpected behavior: Third assignment should raise an error
Actual behavior: Assignment is allowed
Related Issues: No found any
Code
Output
Compiler Options
{ "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true, "strictFunctionTypes": true, "strictPropertyInitialization": true, "strictBindCallApply": true, "noImplicitThis": true, "noImplicitReturns": true, "useDefineForClassFields": false, "alwaysStrict": true, "allowUnreachableCode": false, "allowUnusedLabels": false, "downlevelIteration": false, "noEmitHelpers": false, "noLib": false, "noStrictGenericChecks": false, "noUnusedLocals": false, "noUnusedParameters": false, "esModuleInterop": true, "preserveConstEnums": false, "removeComments": false, "skipLibCheck": false, "checkJs": false, "allowJs": false, "declaration": true, "experimentalDecorators": false, "emitDecoratorMetadata": false, "target": "ES2017", "module": "ESNext" } }Playground Link:Provided