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

AsyncIterable still raises compile issue with 3.6.1 if target is not set to ES2018 #14029

Closed
ibdafna opened this issue Feb 17, 2023 · 7 comments
Labels
documentation status:Answered The issue has been answered by a community member. status:Closing as Answered The issue will be closed soon as answered unless there is further follow-up.

Comments

@ibdafna
Copy link
Member

ibdafna commented Feb 17, 2023

Seems to be caused by the following line:
https://github.com/jupyterlab/jupyterlab/blob/3.6.x/packages/services/src/event/index.ts#L183

➜ jlpm build
yarn run v1.21.1
$ jlpm build:lib && jlpm build:labextension:dev
$ tsc --sourceMap
node_modules/@jupyterlab/services/lib/event/index.d.ts:89:52 - error TS2583: Cannot find name 'AsyncIterable'. Do you need to change your target library? Try changing the `lib` compiler option to 'es2018' or later.

89     interface IStream<T, U> extends ISignal<T, U>, AsyncIterable<U> {
                                                      ~~~~~~~~~~~~~


Found 1 error.

error Command failed with exit code 1.
@ibdafna ibdafna added the bug label Feb 17, 2023
@jupyterlab-probot jupyterlab-probot bot added the status:Needs Triage Applied to new issues that need triage label Feb 17, 2023
@krassowski
Copy link
Member

Is this with 3.6.0 or 3.6.1? See previous discussion in #13913.

@ibdafna
Copy link
Member Author

ibdafna commented Feb 18, 2023

It's with 3.6.1

@fcollonval
Copy link
Member

To fix this in extension, see the migration note in the documentation: https://jupyterlab.readthedocs.io/en/stable/extension/extension_migration.html#asynciterable-support

@fcollonval fcollonval added documentation status:Answered The issue has been answered by a community member. and removed bug labels Mar 6, 2023
@ibdafna
Copy link
Member Author

ibdafna commented Mar 6, 2023

Thanks @fcollonval, I saw the migration guide but I'm still confused because it does say the target was reverted to ES2017 in JLab 3.6.1, which does not seem to be the case.

JupyterLab 3.6.0 was released with an updated target “ES2018”. We strongly advise updating to 3.6.1, which reverts the target back to “ES2017”.

@fcollonval
Copy link
Member

The target is changing the produced JS assets but not the typing files. Therefore the .d.ts emitted still contain AsyncIterable types. If you don't want to change the target in your downstream extension, you need to inform typescript on the types it does not know. You can do this by adding ES2018 to the lib TS option - this is similar to adding/bumping @types/ package.

You could also use skipLibCheck - but this is a bad practice.

@krassowski
Copy link
Member

We could try shipping our custom types patch in the future to avoid breaking the developer experience for extension developers. I used this approach when backporting content-visibility mode in lumino without switching target: jupyterlab/lumino#500 by patching up CSSStyleDeclaration interface. Would that work?

@fcollonval
Copy link
Member

fcollonval commented Mar 7, 2023

We could try shipping our custom types patch in the future to avoid breaking the developer experience for extension developers. I used this approach when backporting content-visibility mode in lumino without switching target: jupyterlab/lumino#500 by patching up CSSStyleDeclaration interface. Would that work?

That is a good question. Looking at the typescript type definition:

/// <reference lib="es2015.symbol" />
/// <reference lib="es2015.iterable" />

interface SymbolConstructor {
    /**
     * A method that returns the default async iterator for an object. Called by the semantics of
     * the for-await-of statement.
     */
    readonly asyncIterator: symbol;
}

interface AsyncIterator<T, TReturn = any, TNext = undefined> {
    // NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
    next(...args: [] | [TNext]): Promise<IteratorResult<T, TReturn>>;
    return?(value?: TReturn | PromiseLike<TReturn>): Promise<IteratorResult<T, TReturn>>;
    throw?(e?: any): Promise<IteratorResult<T, TReturn>>;
}

interface AsyncIterable<T> {
    [Symbol.asyncIterator](): AsyncIterator<T>;
}

interface AsyncIterableIterator<T> extends AsyncIterator<T> {
    [Symbol.asyncIterator](): AsyncIterableIterator<T>;
}

it seems possible. But I have no idea if this will always be the case - I guess if some new fundamental type were to be defined it won't be possible.

@github-actions github-actions bot added the status:Closing as Answered The issue will be closed soon as answered unless there is further follow-up. label Mar 15, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 20, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation status:Answered The issue has been answered by a community member. status:Closing as Answered The issue will be closed soon as answered unless there is further follow-up.
Projects
None yet
Development

No branches or pull requests

3 participants