Skip to content

types missing with --lib #8097

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

Closed
alexeagle opened this issue Apr 14, 2016 · 4 comments
Closed

types missing with --lib #8097

alexeagle opened this issue Apr 14, 2016 · 4 comments

Comments

@alexeagle
Copy link
Contributor

I worked around #8091 by adding to the top of lib.webworker.d.ts

interface IDBIndexParameters {
    multiEntry?: boolean;
    unique?: boolean;
}
type IDBKeyPath = string;
interface IDBObjectStoreParameters {
    autoIncrement?: boolean;
    keyPath?: IDBKeyPath;
}

now I get another error:

TypeScript Version:

nightly (1.9.0-dev.20160409)

Code

$ npm install rxjs
$ cat tsconfig.json
{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es5",
        "lib": ["webworker", "es6"],
        "noImplicitAny": false,
        "sourceMap": false
    },
    "exclude": [
        "node_modules"
    ],
    "files": ["repro.ts"]
}
$ cat repro.ts
import * as o from 'rxjs/observable/FromEventObservable';
node_modules/rxjs/observable/FromEventObservable.d.ts(11,104): error TS2304: Cannot find name 'NodeList'.
node_modules/rxjs/observable/FromEventObservable.d.ts(11,115): error TS2304: Cannot find name 'HTMLCollection'.
@mhegazy
Copy link
Contributor

mhegazy commented Apr 14, 2016

do not think HTMLCollection or NodeList are available for webworkers. webworkers should not have access to the dom.

@alexeagle
Copy link
Contributor Author

webworkers was a red herring here, I can also repro with:

$cat repro.ts
import * as o from 'rxjs/observable/FromEventObservable';
$cat tsconfig.json
{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es5",
        "lib": ["es6"],
        "noImplicitAny": false,
        "sourceMap": false
    },
    "exclude": [
        "node_modules"
    ],
    "files": ["repro.ts"]
}
$./node_modules/.bin/tsc
node_modules/rxjs/observable/FromEventObservable.d.ts(11,39): error TS2304: Cannot find name 'EventTarget'.
node_modules/rxjs/observable/FromEventObservable.d.ts(11,104): error TS2304: Cannot find name 'NodeList'.
node_modules/rxjs/observable/FromEventObservable.d.ts(11,115): error TS2304: Cannot find name 'HTMLCollection'.

@alexeagle
Copy link
Contributor Author

oh, I see, I need lib: ["es6", "dom"]

This is a problem in angular2 compilation, where we currently compile code that's meant to run in a webworker in the same compilation unit with code that runs in browser, so I would need all the types from

lib: ["es6", "dom", "webworker"]
but that gives lots of TS2300 Duplicate identifier errors.

It's too bad that any code depending on angular2 has to typecheck the angular2 .d.ts files, as they contain a mix of webworker and browser code. I can compile with --target=es6 but as soon as I change to --target=es5 there seems to be no value for the --lib flag that makes the typechecking succeed again.

@alexeagle
Copy link
Contributor Author

Actually, now I cannot reproduce a need for both dom and webworker. Maybe the workaround for #8091 actually solved all my problems.

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants