[api] Fix compatibility with older @types/node and exactOptionalPropertyTypes#4497
Merged
andrewbranch merged 2 commits intoJul 1, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses type-checking failures for consumers of the native-preview programmatic APIs when exactOptionalPropertyTypes: true is enabled and older @types/node versions are used, by tightening the package’s TS configuration and adjusting emitted/public API type shapes for optional properties and TextDecoder.
Changes:
- Enable
exactOptionalPropertyTypesfor native-preview builds and relax test-only typechecking viaskipLibCheckto accommodate third-party deps. - Update API surface typings so optional properties are compatible under
exactOptionalPropertyTypes(e.g., explicitly allowing| undefinedwhere required). - Add a local
TextDecodertype to avoid relying on newer@types/nodeglobal type declarations.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| _packages/native-preview/tsconfig.base.json | Enables exactOptionalPropertyTypes for the package. |
| _packages/native-preview/test/tsconfig.json | Sets skipLibCheck for the test project (workaround for tinybench). |
| _packages/native-preview/src/ast/ast.ts | Adjusts Node.jsDoc optional typing for exact-optional compatibility. |
| _packages/native-preview/src/api/sync/types.ts | Updates optional properties to explicitly include ` |
| _packages/native-preview/src/api/sync/api.ts | Updates exported API surface and optional properties (generated sync API). |
| _packages/native-preview/src/api/node/node.ts | Imports TextDecoder as a type from infrastructure module. |
| _packages/native-preview/src/api/node/node.infrastructure.ts | Introduces a TextDecoder interface to support older @types/node. |
| _packages/native-preview/src/api/async/types.ts | Updates optional properties to explicitly include ` |
| _packages/native-preview/src/api/async/api.ts | Updates optional properties to explicitly include ` |
Comments suppressed due to low confidence (1)
_packages/native-preview/src/api/sync/api.ts:121
src/api/sync/api.tsis marked as auto-generated fromsrc/api/async/api.ts(see header andscripts/generateSync.ts). Adding__Stringto the sync export list without making the same change in the async source means the change will be lost the next timenpm run generate:syncis run. Please add/adjust the export insrc/api/async/api.ts(or add a sync directive) and regenerate the sync output.
export { CompletionItemKind, DiagnosticCategory, ElementFlags, ModifierFlags, ModuleKind, NodeBuilderFlags, ObjectFlags, SignatureFlags, SignatureKind, SymbolFlags, TypeFlags, TypePredicateKind };
export type { APIOptions, ClientSocketOptions, ClientSpawnOptions, DocumentIdentifier, DocumentPosition, LSPConnectionOptions, SourceFileMetadata };
export type { AssertsIdentifierTypePredicate, AssertsThisTypePredicate, BigIntLiteralType, BooleanLiteralType, CompletionEntry, CompletionInfo, CompletionOptions, ConditionalType, Diagnostic, FreshableType, IdentifierTypePredicate, IndexedAccessType, IndexInfo, IndexType, InterfaceType, IntersectionType, IntrinsicType, JSDocTagInfo, LiteralType, NumberLiteralType, ObjectType, StringLiteralType, StringMappingType, SubstitutionType, TemplateLiteralType, ThisTypePredicate, TupleType, Type, TypeParameter, TypePredicate, TypePredicateBase, TypeReference, UnionOrIntersectionType, UnionType };
Comment on lines
+41
to
+45
| // The global type is not available in earlier @types/node versions | ||
| export interface TextDecoder { | ||
| decode(input?: ArrayBufferView | ArrayBufferLike): string; | ||
| } | ||
|
|
Member
Author
There was a problem hiding this comment.
wtf8.ts is not part of the public API so it doesn't enter a consumer's program
jakebailey
approved these changes
Jul 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4405