Skip to content

TypeError: Cannot read property 'toLowerCase' of undefined #29623

@timocov

Description

@timocov

TypeScript Version: 3.3.0-dev.20190126, 3.2.4

Search Terms: toLowerCase, TypeError, extendable configs

Code

tsconfig.json

{
	"compilerOptions": {
		"composite": true
	},
	"references": [
		{ "path": "./tsconfig.first.json" },
		{ "path": "./tsconfig.second.json" }
	]
}

tsconfig.first.json

{
	"extends": "./foobar.json",
	"compilerOptions": {
		"composite": true
	}
}

tsconfig.second.json

{
	"extends": "./foobar.json",
	"compilerOptions": {
		"composite": true
	}
}

tsc -b tsconfig.json

Expected behavior:

error TS5058: The specified path does not exist: 'foobar.json'.

Actual behavior:

TypeError: Cannot read property 'toLowerCase' of undefined

The reason of that error is somewhere here: https://github.com/Microsoft/TypeScript/blob/fa74cef81e488c8e5bf790020620f0226118cb58/src/compiler/program.ts#L225-L244

I don't know how it is even compiled, because readFileCache is map for string | false, so readFileCache.get() mush return string | false | undefined and after checking if (value !== undefined) in host.readFile function type of the value should be string | false, what is not assigned to string | undefined (according scriptNullChecks flag enabled).

UPD: setReadFileCache returns any (due disabled strictBindCallApply compiler option), that's why there is no error.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions