Skip to content
This repository has been archived by the owner on Feb 9, 2023. It is now read-only.

Ambient global namespace not found #18

Closed
kuon opened this issue Jun 10, 2016 · 7 comments
Closed

Ambient global namespace not found #18

kuon opened this issue Jun 10, 2016 · 7 comments

Comments

@kuon
Copy link

kuon commented Jun 10, 2016

I am trying to use the youtube definition file https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/youtube/youtube.d.ts

This file is referenced from my app.ts file with /// <reference path="youtube.d.ts" />.

I can compile my app.ts file with tsc -m commonjs, but with brunch, I got:
Error 2503: Cannot find namespace 'YT'. (Line: 104, Col: 28)

If I copy the content of the youtube.d.ts file in my app.ts brunch can then compile it.

Any idea?

@baptistedonaux
Copy link
Contributor

Hi @kuon,

Sorry the waiting. If you have always the problem, I can take few minutes to check that this issue is not thrown by brunch-typescript.

@CarsonF
Copy link

CarsonF commented Jun 28, 2016

I'm having the same problem. But only with some of the uses which is weird.

@CarsonF
Copy link

CarsonF commented Jun 28, 2016

Just ignoring the error seemed to work for me.

plugins: {
  brunchTypescript: {
    ignoreErrors: [
      2503 // Cannot find namespace {0}
    ]
  }
}

@colinbate
Copy link
Contributor

Sorry, I should have chimed in earlier. This plugin runs TypeScript in a single file isolation mode. That means that it looks at each file without any outside context. It makes it faster, but it is also a lot less "intelligent". When we started surfacing errors, it was obvious that many of the errors were because of this mode. Finding outside namespaces is obviously one such error. We can add it to the list which are ignored by default which will help in this case.

I had started looking into an option to run the full typescript language server as part of compilation (perhaps when doing a regular build without watching). I didn't get very far with that.

If you are using this plugin, I recommend adding tsc --noEmit as part of your npm test script. That should catch any proper TS errors. Your editor may also be catching them, but it is nice to have something you can run in your CI tool.

@CarsonF
Copy link

CarsonF commented Jun 28, 2016

Ah that's why tsc catches more errors than this does. Thanks for --noEmit hint.

@baptistedonaux
Copy link
Contributor

@colinbate Can you improve brunch-typescript in any way ?

@kuon
Copy link
Author

kuon commented Jun 29, 2016

@baptistedonaux I think it would require using the typescript service.

When I was using browserify, I was using https://github.com/TypeStrong/tsify which uses the typescript services.

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

No branches or pull requests

5 participants