-
Notifications
You must be signed in to change notification settings - Fork 520
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
BUILD file generation doesn't understand the @types convention for scoped packages #1033
Comments
I made a minimal repro in a fresh dir without Bazel involved: $ yarn init -y
$ yarn add [email protected] # Also repros at 3.5.3 and 3.7.0-dev.20191014
$ yarn add @types/node @types/babel__traverse
$ mkdir my_types
$ mv node_modules/@types/* my_types
Then a simple
The "fs" import works, but the Interestingly this appears in the output:
Doesn't actually seem to matter if my_types/babel__traverse/index.d.ts is in the program (listed in It seems like the |
microsoft/TypeScript#30599 describes how typeRoots doesn't actually affect the module resolution. The workaround suggested there does work wrap the content of
I think that's the most straightforward way to get this to work under |
These were getting included in the @angular/localize package. Instead, patch the upstream files to work with TS typeRoots option See bazel-contrib/rules_nodejs#1033
These were getting included in the @angular/localize package. Instead, patch the upstream files to work with TS typeRoots option See bazel-contrib/rules_nodejs#1033
These were getting included in the @angular/localize package. Instead, patch the upstream files to work with TS typeRoots option See bazel-contrib/rules_nodejs#1033 PR Close #33176
This isn't a bazel/rules_nodejs bug, it's just an interaction of TypeScript with the typeRoots feature that we use. angular/angular#33176 shows how Angular worked around it. |
These were getting included in the @angular/localize package. Instead, patch the upstream files to work with TS typeRoots option See bazel-contrib/rules_nodejs#1033
These were getting included in the @angular/localize package. Instead, patch the upstream files to work with TS typeRoots option See bazel-contrib/rules_nodejs#1033
These were getting included in the @angular/localize package. Instead, patch the upstream files to work with TS typeRoots option See bazel-contrib/rules_nodejs#1033 PR Close #33226
These were getting included in the @angular/localize package. Instead, patch the upstream files to work with TS typeRoots option See bazel-contrib/rules_nodejs#1033 PR Close angular#33176
These were getting included in the @angular/localize package. Instead, patch the upstream files to work with TS typeRoots option See bazel-contrib/rules_nodejs#1033 PR Close angular#33226
These were getting included in the @angular/localize package. Instead, patch the upstream files to work with TS typeRoots option See bazel-contrib/rules_nodejs#1033 PR Close angular#33176
These were getting included in the @angular/localize package. Instead, patch the upstream files to work with TS typeRoots option See bazel-contrib/rules_nodejs#1033 PR Close angular#33226
@alexeagle also seeing this while migrating the CLI repo to Bazel. Patching node_modules contents (what was done here) doesn't really sound like it should be the answer here. The typeRoots interaction might be unexpected but it's not part of the user configuration so it's not as if a rules_typescript user is opting into the weirdness. It's something that rules_typescript adds to make the setup work. microsoft/TypeScript#30599 (comment) makes it sound like this isn't a TS bug at all either, but rather that I don't really understand why the issue was closed. It's not a typescript bug, it's not user error, it's not a problem without rules_typescript, and there's no workaround besides "use different dependencies or change them". It really sounds like it's a bug in rules_typescript use of typescript. |
Here's a more ergonomic approach: make a
This might need TS 3.8 for https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#export-star-as-namespace-syntax. |
…s.d.ts` during bazel builds `packages/angular_devkit/build_angular/src/typings.d.ts` is only needed for a Bazel build to workaround bazel-contrib/rules_nodejs#1033 Including this typings in a non Bazel build creates broken triple slash references https://unpkg.com/browse/@angular-devkit/[email protected]/src/utils/process-bundle.d.ts
Context from Angular slack: https://angular-team.slack.com/archives/C4WCRN728/p1565947484085800
Pete Bacon Darwin
Does anyone have any ideas why this is failing: https://circleci.com/gh/angular/angular/425302 and how to fix it?
You’ll notice that the
packages/localize/inlining:inlining
build is failing because it cannot find the type declaration for@babel/core
. (edited)But I have installed the
@types/babel__core
typings in npm and inside VS Code it is able to find the typings correctly.I think it might be related to the mapping of namespace in the package name to __ in the DefinitelyTyped package. I.E. @babel/core => babel__core.
I see in the generated tsconfig.json for the rule there is the following paths entry:
I wonder if this explicit path is causing TS in the ts_library rule to only try external/npm/node_modules/@types/@babel/core, which obviously doesn’t exist?
From looking at this: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master#what-about-scoped-packages
I think we need to add this to the paths.
Is that possible with ts_library?
Alex Eagle 9:21 AM
interesting, I had no idea they did this kind of transform. we should be able to easily do this automatically in tsconfig.bzl
your workaround is probably to patch a PR
somewhere around here https://github.com/bazelbuild/rules_typescript/blob/master/internal/common/tsconfig.bzl#L119
The text was updated successfully, but these errors were encountered: