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

Use typescript 3.2.x #922

Merged
merged 7 commits into from
Jan 2, 2019
Merged

Use typescript 3.2.x #922

merged 7 commits into from
Jan 2, 2019

Conversation

Wenzil
Copy link
Contributor

@Wenzil Wenzil commented Dec 19, 2018

Allows generating documentation for projects requiring TypeScript 3.2

@Wenzil
Copy link
Contributor Author

Wenzil commented Dec 19, 2018

There seems to be a type inference change with TypeScript 3.2 for the following statement

const [destructArrayWithIgnoresA, , ...destructArrayWithIgnoresRest] = [1, 2, 3, 4];

With typescript 3.1, destructArrayWithIgnoresRest is inferred to number[], while in 3.2, it is inferred to the [number, number] tuple.

@aciccarello
Copy link
Collaborator

This should allow #881 to be merged as well

@Wenzil
Copy link
Contributor Author

Wenzil commented Dec 19, 2018

So I'm not sure how to make TypeDoc aware of the new type inference for fixed-size array destructuring with ...rest mentioned in my previous comment.

I tried to follow the steps described in UPDATING.md, but on the grunt ts:typescript step I get a ton of errors:

error TS2304: Cannot find name 'createGetSymbolWalker'.
error TS2304: Cannot find name 'mangleScopedPackageName'.
error TS2304: Cannot find name 'getTypesPackageName'.
error TS2304: Cannot find name 'createKeywordTypeNode'.
error TS2304: Cannot find name 'createTypeReferenceNode'.
error TS2304: Cannot find name 'createLiteralTypeNode'.
error TS2304: Cannot find name 'setEmitFlags'.
error TS2304: Cannot find name 'createLiteral'.
error TS2304: Cannot find name 'createTrue'.
error TS2304: Cannot find name 'createFalse'.
error TS2304: Cannot find name 'createTypeOperatorNode'.
error TS2304: Cannot find name 'createThis'.
error TS2304: Cannot find name 'createInferTypeNode'.
error TS2304: Cannot find name 'getGeneratedNameForNode'.
error TS2304: Cannot find name 'createIdentifier'.
error TS2304: Cannot find name 'createUnionOrIntersectionTypeNode'.
error TS2304: Cannot find name 'createIndexedAccessTypeNode'.
error TS2304: Cannot find name 'createConditionalTypeNode'.
error TS2304: Cannot find name 'createToken'.
error TS2304: Cannot find name 'createMappedTypeNode'.
error TS2304: Cannot find name 'createTypeLiteralNode'.
error TS2304: Cannot find name 'createArrayTypeNode'.
error TS2304: Cannot find name 'createRestTypeNode'.
error TS2304: Cannot find name 'createOptionalTypeNode'.
error TS2304: Cannot find name 'createTupleTypeNode'.
error TS2304: Cannot find name 'createQualifiedName'.
error TS2304: Cannot find name 'createPropertySignature'.
error TS2304: Cannot find name 'setCommentRange'.
error TS2304: Cannot find name 'createParameter'.
error TS2304: Cannot find name 'createIndexSignature'.
error TS2304: Cannot find name 'createThisTypeNode'.
error TS2304: Cannot find name 'createTypePredicateNode'.
error TS2304: Cannot find name 'createSignatureDeclaration'.
error TS2304: Cannot find name 'createTypeParameterDeclaration'.
error TS2304: Cannot find name 'getSynthesizedClone'.
error TS2304: Cannot find name 'visitEachChild'.
error TS2304: Cannot find name 'nullTransformationContext'.
error TS2304: Cannot find name 'moduleSpecifiers'.
error TS2304: Cannot find name 'createNodeArray'.
error TS2339: Property 'right' does not exist on type 'QualifiedName | IndexedAccessTypeNode'.
error TS2304: Cannot find name 'createImportTypeNode'.
error TS2304: Cannot find name 'createTypeQueryNode'.
error TS2304: Cannot find name 'createPropertyAccess'.
error TS2304: Cannot find name 'createElementAccess'.
error TS2740: Type 'ReadonlyArray<Type>' is missing the following properties from type 'Type[]': pop, push, reverse, shift, and 3 more.
error TS2339: Property 'next' does not exist on type 'IterableIterator<{ errorNode: Node; innerExpression: Expression; nameType: Type; errorMessage?: DiagnosticMessage; }>'.
error TS2339: Property 'assertNode' does not exist on type 'typeof Debug'.
error TS2339: Property 'next' does not exist on type 'IterableIterator<Symbol>'.
error TS2304: Cannot find name 'skipOuterExpressions'.
error TS2304: Cannot find name 'createFunctionTypeNode'.
error TS2304: Cannot find name 'OuterExpressionKinds'.
error TS2304: Cannot find name 'findUseStrictPrologue'.
error TS2448: Block-scoped variable 'Diagnostics' used before its declaration.
error TS2304: Cannot find name 'BuildOptions'.
error TS4033: Property 'buildOptions' of exported interface has or is using private name 'BuildOptions'.
error TS2304: Cannot find name 'nodeModuleNameResolver'.
error TS2339: Property 'next' does not exist on type 'Iterator<any> | IterableIterator<any>'.
error TS2339: Property 'fill' does not exist on type 'any[]'.
error TS2304: Cannot find name 'createBundle'.
error TS2339: Property 'createTimer' does not exist on type 'Performance'.
error TS2304: Cannot find name 'transformNodes'.
error TS2304: Cannot find name 'transformDeclarations'.
error TS2304: Cannot find name 'createSourceMapGenerator'.
error TS2304: Cannot find name 'noEmitNotification'.
error TS2304: Cannot find name 'noEmitSubstitution'.
error TS2339: Property 'createTimerIf' does not exist on type 'Performance'.
error TS2304: Cannot find name 'getExternalHelpersModuleName'.
error TS2304: Cannot find name 'getEmitHelpers'.
error TS2304: Cannot find name 'compareEmitHelpers'.
error TS2339: Property 'scoped' does not exist on type '{}'.
error TS2339: Property 'name' does not exist on type '{}'.
error TS2339: Property 'text' does not exist on type '{}'.
error TS2304: Cannot find name 'getConstantValue'.
error TS2304: Cannot find name 'getCommentRange'.
error TS2304: Cannot find name 'getStartsOnNewLine'.
error TS2304: Cannot find name 'getSyntheticLeadingComments'.
error TS2304: Cannot find name 'getSyntheticTrailingComments'.
error TS2304: Cannot find name 'tryParseRawSourceMap'.
error TS2304: Cannot find name 'getSourceMapRange'.
error TS2304: Cannot find name 'ModuleResolutionCache'.
error TS2304: Cannot find name 'createModuleResolutionCache'.
error TS2304: Cannot find name 'resolveModuleName'.
error TS2304: Cannot find name 'resolveTypeReferenceDirective'.
error TS2304: Cannot find name 'getAutomaticTypeDirectiveNames'.
error TS2304: Cannot find name 'resolveModuleNameFromCache'.
error TS2304: Cannot find name 'isTraceEnabled'.
error TS2304: Cannot find name 'trace'.
error TS2304: Cannot find name 'createInputFiles'.
error TS2304: Cannot find name 'getTransformers'.
error TS2551: Property 'getDeclarationDiagnostics' does not exist on type 'typeof ts'. Did you mean 'getResolutionDiagnostic'?
error TS2304: Cannot find name 'createImportDeclaration'.
error TS2304: Cannot find name 'addEmitFlags'.
error TS2304: Cannot find name 'getOutputDeclarationFileName'.
error TS2304: Cannot find name 'resolveConfigFileProjectName'.
error TS2552: Cannot find name 'closeFileWatcherOf'. Did you mean 'closeFileWatcher'?

Sami Turcotte added 2 commits December 19, 2018 13:33
@Wenzil
Copy link
Contributor Author

Wenzil commented Dec 19, 2018

I updated the destructuring specs to match what I would expect from TypeScript 3.2. Any pointers on how to meet these updated specs? I'd like to get the tests to pass.

@aciccarello
Copy link
Collaborator

Try running the npx grunt update-specs task. It should update the specs so you can commit the changes.

awol55 pushed a commit to awol55/typedoc that referenced this pull request Dec 22, 2018
@aciccarello
Copy link
Collaborator

@Gerrit0 Could you share a bit more about what you learned around the tuple converter logic?

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Dec 30, 2018

@aciccarello I still don't really understand what's going on with tuples, I suspect there might be a bug where the ts.ObjectFlags.Tuple flag is not set for a destructured element, but I don't understand enough about the compiler to confirm this.

Arrays are also weird, the tuple type check I came up with is basically the same as the array type check here:

supportsType(context: Context, type: ts.TypeReference): boolean {
// Is there a better way to detect the {"type":"reference","name":"Array","typeArguments":{...}} types that are in fact arrays?
return !!(type.flags & ts.TypeFlags.Object)
&& !!type.symbol
&& type.symbol.name === 'Array'
&& !type.symbol.parent
&& !!type.typeArguments
&& type.typeArguments.length === 1;
}

I've opened ts-simple-ast#519 as David's library seems to have the same issue, and he might already know why this is happening.

@Gerrit0 Gerrit0 merged commit b2f4134 into TypeStrong:master Jan 2, 2019
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jan 2, 2019

Thanks for your patience while figuring everything out! I clearly have more to learn about the type system.

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

Successfully merging this pull request may close these issues.

3 participants