Skip to content

Commit

Permalink
chore: use "import type" in the Typescript SDK (#623)
Browse files Browse the repository at this point in the history
Change in codegen, and in the generated TS SDKs
  • Loading branch information
jkaster authored Apr 22, 2021
1 parent 581b351 commit c7b5bf8
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 41 deletions.
22 changes: 13 additions & 9 deletions packages/sdk-codegen/src/typescript.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,15 @@ export class TypescriptGen extends CodeGen {

methodsPrologue(_indent: string) {
return `
import { ${this.rtlImports()}APIMethods, IAuthSession, ITransportSettings, encodeParam, SDKResponse } from '@looker/sdk-rtl'
import type { ${this.rtlImports()}IAuthSession, ITransportSettings, SDKResponse } from '@looker/sdk-rtl'
import { APIMethods, encodeParam } from '@looker/sdk-rtl'
/**
* ${this.warnEditing()}
*
*/
import { sdkVersion } from '../constants'
import { I${this.packageName} } from './methodsInterface'
import { ${this.typeNames().join(', ')} } from './models'
import type { I${this.packageName} } from './methodsInterface'
import type { ${this.typeNames().join(', ')} } from './models'
export class ${this.packageName} extends APIMethods implements I${
this.packageName
Expand All @@ -127,15 +128,16 @@ export class ${this.packageName} extends APIMethods implements I${

functionsPrologue(_indent: string) {
return `
import { ${this.rtlImports()}IAPIMethods, ITransportSettings, IAuthSession, encodeParam, SDKResponse, functionalSdk } from '@looker/sdk-rtl'
import type { ${this.rtlImports()}IAPIMethods, IAuthSession, ITransportSettings, SDKResponse } from '@looker/sdk-rtl'
import { encodeParam, functionalSdk } from '@looker/sdk-rtl'
/**
* ${this.warnEditing()}
*
*/
import { sdkVersion } from '../constants'
import { ${this.typeNames().join(', ')} } from './models'
import type { ${this.typeNames().join(', ')} } from './models'
/**
* Creates a "functional sdk" that knows the API and Looker release version
Expand All @@ -152,12 +154,12 @@ export const functionalSdk${this.apiRef} = (

interfacesPrologue(_indent: string) {
return `
import { ${this.rtlImports()} ITransportSettings, SDKResponse } from '@looker/sdk-rtl'
import type { ${this.rtlImports()} ITransportSettings, SDKResponse } from '@looker/sdk-rtl'
/**
* ${this.warnEditing()}
*
*/
import { ${this.typeNames().join(', ')} } from './models'
import type { ${this.typeNames().join(', ')} } from './models'
export interface I${this.packageName} {
Expand All @@ -167,13 +169,15 @@ export interface I${this.packageName} {
streamsPrologue(_indent: string): string {
return `
import { Readable } from 'readable-stream'
import { ${this.rtlImports()}APIMethods, IAuthSession, ITransportSettings, encodeParam } from '@looker/sdk-rtl'
import type { ${this.rtlImports()}IAuthSession, ITransportSettings } from '@looker/sdk-rtl'
import { APIMethods, encodeParam } from '@looker/sdk-rtl'
/**
* ${this.warnEditing()}
*
*/
import { sdkVersion } from '../constants'
import { ${this.typeNames().join(', ')} } from './models'
import type { ${this.typeNames().join(', ')} } from './models'
export class ${this.packageName}Stream extends APIMethods {
static readonly ApiVersion = '${this.apiVersion}'
Expand Down
9 changes: 4 additions & 5 deletions packages/sdk/src/3.1/funcs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,23 @@
* 375 API methods
*/

import {
import type {
DelimArray,
IDictionary,
IAPIMethods,
ITransportSettings,
IAuthSession,
encodeParam,
ITransportSettings,
SDKResponse,
functionalSdk,
} from '@looker/sdk-rtl'
import { encodeParam, functionalSdk } from '@looker/sdk-rtl'

/**
* NOTE: Do not edit this file generated by Looker SDK Codegen for Looker 21.4 API 3.1
*
*/

import { sdkVersion } from '../constants'
import {
import type {
IAccessToken,
IApiSession,
IApiVersion,
Expand Down
9 changes: 4 additions & 5 deletions packages/sdk/src/3.1/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,21 @@
* 375 API methods
*/

import {
import type {
DelimArray,
IDictionary,
APIMethods,
IAuthSession,
ITransportSettings,
encodeParam,
SDKResponse,
} from '@looker/sdk-rtl'
import { APIMethods, encodeParam } from '@looker/sdk-rtl'
/**
* NOTE: Do not edit this file generated by Looker SDK Codegen for Looker 21.4 API 3.1
*
*/
import { sdkVersion } from '../constants'
import { ILooker31SDK } from './methodsInterface'
import {
import type { ILooker31SDK } from './methodsInterface'
import type {
IAccessToken,
IApiSession,
IApiVersion,
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/src/3.1/methodsInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* 375 API methods
*/

import {
import type {
DelimArray,
IDictionary,
ITransportSettings,
Expand All @@ -38,7 +38,7 @@ import {
* NOTE: Do not edit this file generated by Looker SDK Codegen for Looker 21.4 API 3.1
*
*/
import {
import type {
IAccessToken,
IApiSession,
IApiVersion,
Expand Down
8 changes: 4 additions & 4 deletions packages/sdk/src/3.1/streams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@
*/

import { Readable } from 'readable-stream'
import {
import type {
DelimArray,
IDictionary,
APIMethods,
IAuthSession,
ITransportSettings,
encodeParam,
} from '@looker/sdk-rtl'
import { APIMethods, encodeParam } from '@looker/sdk-rtl'

/**
* NOTE: Do not edit this file generated by Looker SDK Codegen for Looker 21.4 API 3.1
*
*/
import { sdkVersion } from '../constants'
import {
import type {
IAccessToken,
IApiSession,
IApiVersion,
Expand Down
9 changes: 4 additions & 5 deletions packages/sdk/src/4.0/funcs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,23 @@
* 408 API methods
*/

import {
import type {
DelimArray,
IDictionary,
IAPIMethods,
ITransportSettings,
IAuthSession,
encodeParam,
ITransportSettings,
SDKResponse,
functionalSdk,
} from '@looker/sdk-rtl'
import { encodeParam, functionalSdk } from '@looker/sdk-rtl'

/**
* NOTE: Do not edit this file generated by Looker SDK Codegen for Looker 21.4 API 4.0
*
*/

import { sdkVersion } from '../constants'
import {
import type {
IAccessToken,
IApiSession,
IApiVersion,
Expand Down
9 changes: 4 additions & 5 deletions packages/sdk/src/4.0/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,21 @@
* 408 API methods
*/

import {
import type {
DelimArray,
IDictionary,
APIMethods,
IAuthSession,
ITransportSettings,
encodeParam,
SDKResponse,
} from '@looker/sdk-rtl'
import { APIMethods, encodeParam } from '@looker/sdk-rtl'
/**
* NOTE: Do not edit this file generated by Looker SDK Codegen for Looker 21.4 API 4.0
*
*/
import { sdkVersion } from '../constants'
import { ILooker40SDK } from './methodsInterface'
import {
import type { ILooker40SDK } from './methodsInterface'
import type {
IAccessToken,
IApiSession,
IApiVersion,
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/src/4.0/methodsInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* 408 API methods
*/

import {
import type {
DelimArray,
IDictionary,
ITransportSettings,
Expand All @@ -38,7 +38,7 @@ import {
* NOTE: Do not edit this file generated by Looker SDK Codegen for Looker 21.4 API 4.0
*
*/
import {
import type {
IAccessToken,
IApiSession,
IApiVersion,
Expand Down
8 changes: 4 additions & 4 deletions packages/sdk/src/4.0/streams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@
*/

import { Readable } from 'readable-stream'
import {
import type {
DelimArray,
IDictionary,
APIMethods,
IAuthSession,
ITransportSettings,
encodeParam,
} from '@looker/sdk-rtl'
import { APIMethods, encodeParam } from '@looker/sdk-rtl'

/**
* NOTE: Do not edit this file generated by Looker SDK Codegen for Looker 21.4 API 4.0
*
*/
import { sdkVersion } from '../constants'
import {
import type {
IAccessToken,
IApiSession,
IApiVersion,
Expand Down

0 comments on commit c7b5bf8

Please sign in to comment.