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.0 #72

Closed
evmar opened this issue Jul 16, 2018 · 2 comments
Closed

Support TypeScript 3.0 #72

evmar opened this issue Jul 16, 2018 · 2 comments
Assignees

Comments

@evmar
Copy link

evmar commented Jul 16, 2018

With TypeScript 3.0.0-rc, below failures.

Apparently it's now possible for Nodes to not have any tokens, which I'm not sure how to fix.
The other issues look minor, just some adjusted signatures.

test/rules/control-flow/testCfaRule.ts:32:34 - error TS2345: Argument of type 'Node | undefined' is not assignable to parameter of type 'Node'.
  Type 'undefined' is not assignable to type 'Node'.

32             ctx.addFailureAtNode(node.getFirstToken(ctx.sourceFile), 'control flow end');
                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

test/tokenTests.ts:67:45 - error TS2345: Argument of type 'Node | undefined' is not assignable to parameter of type 'Node'.
  Type 'undefined' is not assignable to type 'Node'.

67         assert.isUndefined(getPreviousToken(sourceFile.getFirstToken()), 'Token');
                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~

util/type.ts:87:5 - error TS2322: Type 'ReadonlyArray<Signature>' is not assignable to type 'Signature[]'.
  Property 'push' is missing in type 'ReadonlyArray<Signature>'.

87     return type.getCallSignatures();
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

util/type.ts:97:61 - error TS2345: Argument of type 'Type | undefined' is not assignable to parameter of type 'Type'.
  Type 'undefined' is not assignable to type 'Type'.

97     for (const ty of unionTypeParts(checker.getApparentType(type))) {
                                                               ~~~~

util/util.ts:85:41 - error TS2345: Argument of type 'Node' is not assignable to parameter of type 'Declaration'.
  Property '_declarationBrand' is missing in type 'Node'.

85     return (ts.getCombinedModifierFlags(node) & flag) !== 0;
                                           ~~~~

util/util.ts:953:15 - error TS2339: Property 'unescapeIdentifier' does not exist on type 'typeof ts'.

953     return ts.unescapeIdentifier ? ts.unescapeIdentifier(node.text) : node.text;
                  ~~~~~~~~~~~~~~~~~~

util/util.ts:953:39 - error TS2339: Property 'unescapeIdentifier' does not exist on type 'typeof ts'.

953     return ts.unescapeIdentifier ? ts.unescapeIdentifier(node.text) : node.text;
                                          ~~~~~~~~~~~~~~~~~~

@ajafff
Copy link
Owner

ajafff commented Jul 16, 2018

IIUC this is not a problem with the library but only occurs when building with a newer TypeScript version?

Regarding "Nodes to not have any tokens": this was possible before. Not the type declarations are just more correct. The cases above can simply be asserted to never be undefined.
That Type | undefined can also be asserted.

ReadonlyArray<Signature> not assignable to Signature[] probably just needs to fix the return type of the containing function.

The (un)escapeIdentifier functions needs an assertion to any.


If you want to fix this, feel free to send a PR. Otherwise I'll try to get this fixed tomorrow.

@evmar
Copy link
Author

evmar commented Jul 16, 2018

These build errors are from updating the version of TypeScript in package.json. Sorry for not being clear.

I'm happy if you fix it, so I can wait. If you are too busy I can otherwise try creating a PR, but I suspect it'll be about as much work for you to review my PR as it would be to fix it directly. :)

@ajafff ajafff self-assigned this Jul 16, 2018
@ajafff ajafff closed this as completed in 8fac0f3 Jul 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants