Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript semantic error: A type predicate's type must be assignable to its parameter's type #3

Open
SeanSobey opened this issue Feb 19, 2018 · 2 comments

Comments

@SeanSobey
Copy link

This comes from the index.d.ts, specifically these 3 functions:

function isNullOrEmpty<T>(seq: IEnumerable<T>): seq is (null | IEnumerable<T>);
function isUndefinedNullOrEmpty<T>(seq: IEnumerable<T>): seq is (undefined | null | IEnumerable<T>);
function isUndefinedOrEmpty<T>(seq: IEnumerable<T>): seq is (undefined | IEnumerable<T>);

I believe the correct semantics, also based on their names and what they should be able to accept as parameters is:

function isNullOrEmpty<T>(seq: null | IEnumerable<T>): seq is (null | IEnumerable<T>);
function isUndefinedNullOrEmpty<T>(seq: undefined | null | IEnumerable<T>): seq is (undefined | null | IEnumerable<T>);
function isUndefinedOrEmpty<T>(seq: undefined | IEnumerable<T>): seq is (undefined | IEnumerable<T>);

I am using typescript 2.7.2.

@mkloubert
Copy link
Owner

@SeanSobey

Do you use compiler options like strict?

@SeanSobey
Copy link
Author

Yes, here is the set of options I am using:

"compilerOptions": {
	"allowJs": true,
	"allowSyntheticDefaultImports": true,
	"checkJs": false,
	"emitDecoratorMetadata": true,
	"experimentalDecorators": true,
	"forceConsistentCasingInFileNames": true,
	"importHelpers": true,
	"module": "commonjs",
	"noFallthroughCasesInSwitch": true,
	"noImplicitAny": false,
	"noImplicitReturns": true,
	"noImplicitThis": true,
	"noUnusedLocals": true,
	"noUnusedParameters": false,
	"pretty": true,
	"skipLibCheck": false,
	"sourceMap": true,
	"strictNullChecks": true,
	"strict": true,
	"target": "es2017"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants