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

Support TypeScript 3.7 #1096

Closed
filipesilva opened this issue Oct 7, 2019 · 4 comments
Closed

Support TypeScript 3.7 #1096

filipesilva opened this issue Oct 7, 2019 · 4 comments
Assignees
Labels
internal-issue-created Google internal issue has been created for this

Comments

@filipesilva
Copy link

While trying to update Angular to typescript@3.7.0-beta in angular/angular#32962, I came across this error emitted by tsickle:

Error: rest parameter does not resolve to a reference type
    at ModuleTypeTranslator.getFunctionTypeJSDoc (/home/circleci/.cache/bazel/_bazel_circleci/9ce5c2144ecf75d11717c0aa41e45a8d/sandbox/processwrapper-sandbox/378/execroot/angular/bazel-out/host/bin/packages/bazel/src/ngc-wrapped/ngc-wrapped.sh.runfiles/npm/node_modules/tsickle/src/module_type_translator.js:424:39)
    at visitFunctionLikeDeclaration (/home/circleci/.cache/bazel/_bazel_circleci/9ce5c2144ecf75d11717c0aa41e45a8d/sandbox/processwrapper-sandbox/378/execroot/angular/bazel-out/host/bin/packages/bazel/src/ngc-wrapped/ngc-wrapped.sh.runfiles/npm/node_modules/tsickle/src/jsdoc_transformer.js:527:75)
    at visitor (/home/circleci/.cache/bazel/_bazel_circleci/9ce5c2144ecf75d11717c0aa41e45a8d/sandbox/processwrapper-sandbox/378/execroot/angular/bazel-out/host/bin/packages/bazel/src/ngc-wrapped/ngc-wrapped.sh.runfiles/npm/node_modules/tsickle/src/jsdoc_transformer.js:913:36)
    at visitNodes (/home/circleci/.cache/bazel/_bazel_circleci/9ce5c2144ecf75d11717c0aa41e45a8d/sandbox/processwrapper-sandbox/378/execroot/angular/bazel-out/host/bin/packages/bazel/src/ngc-wrapped/ngc-wrapped.sh.runfiles/npm/node_modules/typescript/lib/typescript.js:70546:48)
    at visitLexicalEnvironment (/home/circleci/.cache/bazel/_bazel_circleci/9ce5c2144ecf75d11717c0aa41e45a8d/sandbox/processwrapper-sandbox/378/execroot/angular/bazel-out/host/bin/packages/bazel/src/ngc-wrapped/ngc-wrapped.sh.runfiles/npm/node_modules/typescript/lib/typescript.js:70579:22)
...

This corresponds to the following code in tsickle:

                        if (type.flags & ts.TypeFlags.Object &&
                            type.objectFlags & ts.ObjectFlags.Reference) {
                            const typeRef = type;
                            if (!typeRef.typeArguments) {
                                throw new Error('rest parameter does not resolve to a reference type');
                            }
                            type = typeRef.typeArguments[0];
                        }

This seems to be another instance of microsoft/TypeScript#33693, a breaking change that affects Angular. It's easy to work around though:

before:

          const typeReference = type as ts.TypeReference;
          if (typeReference.typeArguments && typeReference.typeArguments.length === 1) {
            return typeReference.typeArguments[0].symbol;
          }

after

          const typeReference = type as ts.TypeReference;
          const typeArguments = this.checker.getTypeArguments(typeReference);
          if (typeArguments.length === 1) {
            return typeArguments[0].symbol;
          }
@brad4d
Copy link
Contributor

brad4d commented Oct 7, 2019

Created Google internal issue http://b/143068853

@brad4d brad4d added the internal-issue-created Google internal issue has been created for this label Oct 7, 2019
@chadbr
Copy link

chadbr commented Nov 7, 2019

Looking forward to 3.7 support! ❤️

@filipesilva
Copy link
Author

This seems to be addressed in the ts37 branch (a1e7cce) and released as tsickle@0.38.0.

@mprobst
Copy link
Contributor

mprobst commented Jan 8, 2020

That's correct @filipesilva

@mprobst mprobst self-assigned this Jan 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal-issue-created Google internal issue has been created for this
Projects
None yet
Development

No branches or pull requests

4 participants