-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Description
TypeScript Version: 3.2.1, 3.3.0-dev.20181204
Search Terms:
--showConfig
Code
Running tsc on any tsconfig.json that has paths in compilerOptions
Example tsconfig.json:
{
"compilerOptions": {
"allowJs": true,
"outDir": "./lib",
"esModuleInterop": true,
"module": "commonjs",
"moduleResolution": "node",
"target": "ES2017",
"sourceMap": true,
"baseUrl": ".",
"paths": {
"@root/*": ["./*"],
"@configs/*": ["src/configs/*"],
"@common/*": ["src/common/*"],
"*": [
"node_modules/*",
"src/types/*"
]
},
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"resolveJsonModule": true
},
"include": [
"./src/**/*"
]
}
Expected behavior:
command-line prints out the effective tsconfig.json
Actual behavior:
this error occured:
TypeError: map.entries is not a function
at Object.forEachEntry (C:\Users\loco\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:6037:28)
at getNameOfCompilerOptionValue (C:\Users\loco\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:20125:19)
at _loop_3 (C:\Users\loco\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:20157:46)
at serializeCompilerOptions (C:\Users\loco\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:20164:13)
at Object.convertToTSConfig (C:\Users\loco\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:20076:25)
at Object.executeCommandLine (C:\Users\loco\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:75680:48)
at Object.<anonymous> (C:\Users\loco\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:75900:4)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
Upon inspecting into tsc.js, realised that function getCustomTypeMapOfCommandLineOption(optionDefinition) was having this behaviour:
function getCustomTypeMapOfCommandLineOption(optionDefinition) {
if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") {
return undefined;
}
else if (optionDefinition.type === "list") {
return getCustomTypeMapOfCommandLineOption(optionDefinition.element);
}
else {
return optionDefinition.type;
}
}
im prospecting that paths optionDefinition, which has a type of 'object', should not have a customTypeMap.
What a customTypeMap does is it maps the string value backs to a numeric value for use later?
Here's a sample for the 'target' options:
{ name: 'target',
shortName: 't',
type:
Map {
'es3' => 0,
'es5' => 1,
'es6' => 2,
'es2015' => 2,
'es2016' => 3,
'es2017' => 4,
'es2018' => 5,
'esnext' => 6 },
// ...
}
With that, i tried modifying function getCustomTypeMapOfCommandLineOption(optionDefinition) to return undefined for optionDefinition.type === "object" and it stops throwing the error:
function getCustomTypeMapOfCommandLineOption(optionDefinition) {
console.log(optionDefinition)
console.log(`optionDefinition.type: ${optionDefinition.type}`)
if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") {
return undefined;
}
else if (optionDefinition.type === "list") {
return getCustomTypeMapOfCommandLineOption(optionDefinition.element);
}
else if (optionDefinition.type === "object") {
return undefined;
}
else {
return optionDefinition.type;
}
}
but im unsure if this is the intended behaviour.
Being a first-timer in open-source, would like some guidance along above and hopefully i can make a pull request for this?
*P.S. thanks for the patience for reading through! pardon for the Bad English 😂