Skip to content

Enable --enforceReadonly in TypeScript code base#59326

Closed
ahejlsberg wants to merge 26 commits intomainfrom
enableEnforceReadonly
Closed

Enable --enforceReadonly in TypeScript code base#59326
ahejlsberg wants to merge 26 commits intomainfrom
enableEnforceReadonly

Conversation

@ahejlsberg
Copy link
Copy Markdown
Member

This PR enables --enforceReadonly in the code base and fixes inconsistencies uncovered by the stricter checking. Note that this requires an updated version of the compiler that includes #58296. Until then, it is possible to compile this branch as follows:

hereby clean
hereby tsc --no-typecheck
hereby build-src --built

A few of the type assertions introduced in this PR are due to inconsistences in Node.d.ts. Once Node.d.ts is updated to properly compile with --enforceReadonly, those assertions can be reverted.

# Conflicts:
#	src/compiler/diagnosticMessages.json
#	tests/baselines/reference/es2018IntlAPIs.types
#	tests/baselines/reference/es2020IntlAPIs.types
#	tests/baselines/reference/inferenceOptionalPropertiesToIndexSignatures.types
#	tests/baselines/reference/instantiationExpressions.types
#	tests/baselines/reference/localesObjectArgument.types
#	tests/baselines/reference/mappedTypeConstraints2.types
#	tests/baselines/reference/mappedTypeRecursiveInference.types
#	tests/baselines/reference/unionTypeInference.types
#	tests/baselines/reference/useObjectValuesAndEntries1.types
#	tests/baselines/reference/useObjectValuesAndEntries4.types
# Conflicts:
#	tests/baselines/reference/api/typescript.d.ts
#	tests/baselines/reference/es2018IntlAPIs.types
#	tests/baselines/reference/es2020IntlAPIs.types
#	tests/baselines/reference/inferenceOptionalPropertiesToIndexSignatures.types
#	tests/baselines/reference/instantiationExpressions.types
#	tests/baselines/reference/localesObjectArgument.types
#	tests/baselines/reference/mappedTypeConstraints2.types
#	tests/baselines/reference/mappedTypeRecursiveInference.errors.txt
#	tests/baselines/reference/unionTypeInference.types
#	tests/baselines/reference/useObjectValuesAndEntries1.types
#	tests/baselines/reference/useObjectValuesAndEntries4.types
@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Jul 17, 2024
@typescript-bot
Copy link
Copy Markdown
Collaborator

Thanks for the PR! It looks like you've changed the TSServer protocol in some way. Please ensure that any changes here don't break consumers of the current TSServer API. For some extra review, we'll ping @sheetalkamat, @mjbvz, @zkat, and @joj for you. Feel free to loop in other consumers/maintainers if necessary.

@typescript-bot
Copy link
Copy Markdown
Collaborator

Looks like you're introducing a change to the public API surface area. If this includes breaking changes, please document them on our wiki's API Breaking Changes page.

Also, please make sure @DanielRosenwasser and @RyanCavanaugh are aware of the changes, just as a heads up.

Comment on lines +2824 to +2825
trace?(s: string): void;
realpath?(path: string): string;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So why did these need to switch away from readonly (and to methods, presumably to exempt some code from readonly checks)?

@typescript-bot
Copy link
Copy Markdown
Collaborator

With 6.0 out as the final release vehicle for this codebase, we're closing all PRs that don't fit the merge criteria for post-6.0 patches. If you think this was a mistake and this PR fits the post-6.0 patch criteria, please post to the 6.0 iteration issue with details (specifically, which PR and which patch criteria it satisfies).

Next steps for PRs:

  • For crash bugfixes or language service improvements, PRs are currently accepted at the typescript-go repo
  • Changes to type system behavior should wait until after 7.0, at which point mainline TypeScript development will resume in this repository with the Go codebase
  • Library file updates (lib.d.ts etc) continue to live in this repo or the DOM Generator repo as appropriate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants