Skip to content

fix: remove deprecated decorator passing in tsconfig path hooks - #2023

Closed
ttshivers wants to merge 1 commit into
nestjs:masterfrom
ttshivers:fix-typescript-5
Closed

fix: remove deprecated decorator passing in tsconfig path hooks#2023
ttshivers wants to merge 1 commit into
nestjs:masterfrom
ttshivers:fix-typescript-5

Conversation

@ttshivers

@ttshiversttshivers commented Apr 9, 2023

Copy link
Copy Markdown

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Other... Please describe:

What is the current behavior?

nest-cli passes decorators to updateImportDeclaration which has been deprecated since typescript v4.8 now that decorators are placed on modifiers in the syntax tree.
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-8.html#decorators-are-placed-on-modifiers-on-typescripts-syntax-trees

nest-cli fails to build with typescript 5 with errors like https://github.com/nestjs/nest-cli/pull/1986/checks?check_run_id=12600352096

> @nestjs/cli@9.3.0 build
> tsc
lib/compiler/hooks/tsconfig-paths.hook.ts:58:26 - error TS2339: Property 'decorators' does not exist on type 'ImportDeclaration'.
58 node.decorators,
~~~~~~~~~~
lib/compiler/hooks/tsconfig-paths.hook.ts:62:21 - error TS2554: Expected 5 arguments, but got 6.
62 node.assertClause,
~~~~~~~~~~~~~~~~~
lib/compiler/hooks/tsconfig-paths.hook.ts:78:26 - error TS2339: Property 'decorators' does not exist on type 'ExportDeclaration'.
78 node.decorators,
~~~~~~~~~~
lib/compiler/hooks/tsconfig-paths.hook.ts:83:21 - error TS2554: Expected 6 arguments, but got 7.
83 node.assertClause,
~~~~~~~~~~~~~~~~~
Found 4 errors in the same file, starting at: lib/compiler/hooks/tsconfig-paths.hook.ts:58
Exited with code exit status 2

Issue Number: N/A

What is the new behavior?

nest-cli no longer emits deprecation warnings and also now successfully builds with typescript 5

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

Decorators are now placed on modifiers on TypeScript's syntax trees.
Passing decorators separately has been deprecated since v4.8 and removed completely in v5.

https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-8.html#decorators-are-placed-on-modifiers-on-typescripts-syntax-trees
microsoft/TypeScript#49089

Comment threadlib/compiler/hooks/tsconfig-paths.hook.ts
@ttshivers
ttshiversforce-pushed the fix-typescript-5 branch 2 times, most recently from 4ad6f34 to 521dc06CompareApril 15, 2023 19:54
@ttshiversttshivers changed the title Update and fix compatibility with typescript 5fix: remove deprecated decorator passing tsconfig path hooksApr 15, 2023
@ttshivers

Copy link
Copy Markdown
Author

I've removed the commit to update typescript to v5 in this commit and just addressed the deprecated decorator passing instead for this PR.

@ttshiversttshivers changed the title fix: remove deprecated decorator passing tsconfig path hooksfix: remove deprecated decorator passing in tsconfig path hooksApr 15, 2023
Decorators are now placed on `modifiers` on TypeScript's syntax trees.
Passing decorators separately has been deprecated since v4.8 and removed
completely in v5.
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-8.html#decorators-are-placed-on-modifiers-on-typescripts-syntax-treesmicrosoft/TypeScript#49089
@kamilmysliwiec

Copy link
Copy Markdown
Member

Let's track this here #2092

@aashir-khan

Copy link
Copy Markdown

@kamilmysliwiec did that PR address the deprecation? I seems like it addressed something else

Sign up for freeto 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

@ttshivers@kamilmysliwiec@aashir-khan