This used to compile but now raises "This expression's type contains type variables that can't be generalized" error

Hello.
This code used to compile but now it’s giving a “This expression’s type contains type variables that can’t be generalized” error.
Also…is there a proper way to get the js iterator without using raw?
Thanks

type _iterable<'a>

type _iterator<'a> = unit => Promise.t<('a, bool)>

let _getIterator :_iterable<'a> => _iterator<'a> = %raw(`
	function (iterable) {
		if(iterable[Symbol.iterator]) {
			let iterator = iterable[Symbol.iterator]()
			return () => {
				let {value, done} = iterator.next()
				return Promise.resolve([value, done])
			}
			
		} else if(iterable[Symbol.asyncIterator]){
			let iterator = iterable[Symbol.asyncIterator]()
			return () => iterator.next().then(({value, done}) => [value, done])
		}
	}
`)

let fromIterable = (iterable :_iterable<'a>) :ReStream_Source.readable<'a> => {

	let iterator: _iterator<'a> = _getIterator(iterable)
	let done = ref(false)

	(sig :ReStream_Source.signal<'a>) => switch sig {
		| Pull(cb) when done.contents => cb(End)
		| Pull(cb) => {
				iterator()
				-> Promise.then(((value, _done)) => {
					if(_done) {
						done := true
						cb(End)
					} else {
						cb(Data(value))
					}
					Promise.resolve()
				})
				-> Promise.catch(err => {
					cb(Error(err))
					Promise.resolve()
				})
				-> ignore
			}
		| Abort => {
				done := true
			}
		}
		
	}

Apparently it works removing type annotations from the raw function.

What would be the proper way to do it though?

Looks like you have weak type variable. There are a couple of threads on here about that that could help you out.

(I couldn’t reproduce your error in the playground or with the latest rescript template. At least the first function…your example has some types that I don’t have access to. Maybe you could post a reproducible example?)