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

Fixing TypeScript 4.5 type generation #519

Merged
merged 3 commits into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ yarn add graphql relay-compiler --dev
yarn add typescript relay-compiler-language-typescript --dev
```

**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.
**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.

## Configuration

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

#### Custom Headers

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

```json
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@
"ts-node": "^10.2.1",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"typescript": "4.4.4"
"typescript": "4.5.2"
},
"peerDependencies": {
"@types/react-relay": ">=11.0.2",
"@types/relay-runtime": ">=12.0.0",
"relay-compiler": ">=12.0.0",
"relay-runtime": ">=12.0.0",
"typescript": ">=4.2.3"
"typescript": ">=4.5.0"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/"
Expand Down
3 changes: 3 additions & 0 deletions src/TypeScriptGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ function aggregateRuntimeImports(ast: ts.Statement[]) {
const importSpecifiers: ts.ImportSpecifier[] = [];
namedImports.map((namedImport) => {
const specifier = ts.factory.createImportSpecifier(
false,
undefined,
ts.factory.createIdentifier(namedImport)
);
Expand Down Expand Up @@ -423,6 +424,7 @@ function importTypes(names: string[], fromModule: string): ts.Statement {
ts.factory.createNamedImports(
names.map((name) =>
ts.factory.createImportSpecifier(
false,
undefined,
ts.factory.createIdentifier(name)
)
Expand Down Expand Up @@ -1083,6 +1085,7 @@ function getFragmentRefsTypeImport(state: State): ts.Statement[] {
undefined,
ts.factory.createNamedImports([
ts.factory.createImportSpecifier(
false,
undefined,
ts.factory.createIdentifier("FragmentRefs")
),
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3541,10 +3541,10 @@ typedarray-to-buffer@^3.1.5:
dependencies:
is-typedarray "^1.0.0"

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

typescript@^3.0.0:
version "3.9.10"
Expand Down