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

ts 5.2 API Change: labeledElementDeclarations can contain undefined #2369

Closed
alex-kinokon opened this issue Aug 22, 2023 · 1 comment
Closed
Labels
bug Functionality does not match expectation

Comments

@alex-kinokon
Copy link

This isn’t really as much as a bug report as a heads-up. TypeScript 5.2 RC contains a breaking change that affects typedoc:

labeledElementDeclarations May Hold undefined Elements

In order to support a mixture of labeled and unlabeled elements, TypeScript’s API has changed slightly. The labeledElementDeclarations property of TupleType may hold undefined for at each position where an element is unlabeled.

  interface TupleType {
-     labeledElementDeclarations?: readonly (NamedTupleMember | ParameterDeclaration)[];
+     labeledElementDeclarations?: readonly (NamedTupleMember | ParameterDeclaration | undefined)[];
  }

Search terms

labeledElementDeclarations, TypeError: Cannot read properties of undefined (reading 'name')

@alex-kinokon alex-kinokon added the bug Functionality does not match expectation label Aug 22, 2023
@WikiRik
Copy link
Contributor

WikiRik commented Aug 24, 2023

Yes, this happens on the newly released TypeScript 5.2.2. A naive update of two lines in the snippet below

if (type.target.labeledElementDeclarations) {
const namedDeclarations = type.target.labeledElementDeclarations;
elements = elements?.map(
(el, i) =>
new NamedTupleMember(
namedDeclarations[i].name.getText(),
!!namedDeclarations[i].questionToken,
removeUndefined(el),
),
);
}

to

                 namedDeclarations[i]!.name.getText(), 
                 !!namedDeclarations[i]!.questionToken, 

casues 10 tests to fail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality does not match expectation
Projects
None yet
Development

No branches or pull requests

2 participants