Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.

Commit bbf8e73

Browse files
authored
Fixing TypeScript 4.5 type generation (#519)
* fixing issues for TypeScript 4.5 * update peer dependenies * update readme
1 parent 45765f7 commit bbf8e73

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ yarn add graphql relay-compiler --dev
1414
yarn add typescript relay-compiler-language-typescript --dev
1515
```
1616

17-
**Note:** Starting with version 14.0.0 relay-compiler-language-typescript requires a minimum TypeScript version of 4.2.3 being installed in your project.
17+
**Note:** Starting with version 15.0.0 relay-compiler-language-typescript requires a minimum TypeScript version of 4.5.0 being installed in your project.
1818

1919
## Configuration
2020

@@ -74,12 +74,12 @@ where the `graphql` function is being used.
7474
*The generated code uses ES2015 module syntax if `module` is set to ES2015 or
7575
higher in your `tsconfig.json`. Note that the `eagerESModules` option from
7676
`relay-compiler` has no effect on the generated code if `module` is ES2015 or
77-
higher.*
77+
higher.*
7878

7979
#### Custom Headers
8080

8181
If you need to add a custom header to generated files, perhaps for a custom linter
82-
or to get boilerplate license code in, that can be passed in also in compilerOptions
82+
or to get boilerplate license code in, that can be passed in also in compilerOptions
8383
as `banner`:
8484

8585
```json

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@
9696
"ts-node": "^10.2.1",
9797
"tslint": "^6.1.3",
9898
"tslint-config-prettier": "^1.18.0",
99-
"typescript": "4.4.4"
99+
"typescript": "4.5.2"
100100
},
101101
"peerDependencies": {
102102
"@types/react-relay": ">=11.0.2",
103103
"@types/relay-runtime": ">=12.0.0",
104104
"relay-compiler": ">=12.0.0",
105105
"relay-runtime": ">=12.0.0",
106-
"typescript": ">=4.2.3"
106+
"typescript": ">=4.5.0"
107107
},
108108
"publishConfig": {
109109
"registry": "https://registry.npmjs.org/"

src/TypeScriptGenerator.ts

+3
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ function aggregateRuntimeImports(ast: ts.Statement[]) {
8787
const importSpecifiers: ts.ImportSpecifier[] = [];
8888
namedImports.map((namedImport) => {
8989
const specifier = ts.factory.createImportSpecifier(
90+
false,
9091
undefined,
9192
ts.factory.createIdentifier(namedImport)
9293
);
@@ -423,6 +424,7 @@ function importTypes(names: string[], fromModule: string): ts.Statement {
423424
ts.factory.createNamedImports(
424425
names.map((name) =>
425426
ts.factory.createImportSpecifier(
427+
false,
426428
undefined,
427429
ts.factory.createIdentifier(name)
428430
)
@@ -1083,6 +1085,7 @@ function getFragmentRefsTypeImport(state: State): ts.Statement[] {
10831085
undefined,
10841086
ts.factory.createNamedImports([
10851087
ts.factory.createImportSpecifier(
1088+
false,
10861089
undefined,
10871090
ts.factory.createIdentifier("FragmentRefs")
10881091
),

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -3541,10 +3541,10 @@ typedarray-to-buffer@^3.1.5:
35413541
dependencies:
35423542
is-typedarray "^1.0.0"
35433543

3544-
typescript@4.4.4:
3545-
version "4.4.4"
3546-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.4.tgz#2cd01a1a1f160704d3101fd5a58ff0f9fcb8030c"
3547-
integrity sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==
3544+
typescript@4.5.2:
3545+
version "4.5.2"
3546+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.2.tgz#8ac1fba9f52256fdb06fb89e4122fa6a346c2998"
3547+
integrity sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==
35483548

35493549
typescript@^3.0.0:
35503550
version "3.9.10"

0 commit comments

Comments
 (0)