Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade to TypeScript 2.7 #289

Merged
merged 2 commits into from
Feb 20, 2018
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
12 changes: 9 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"prettier": "^1.10.2",
"source-map-support": "^0.5.3",
"tmp": "0.0.33",
"typescript": "~2.6.2"
"typescript": "~2.7.0"
},
"files": [
"LICENSE",
Expand Down
2 changes: 1 addition & 1 deletion src/auth/authclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {Credentials} from './credentials';

export abstract class AuthClient {
transporter = new DefaultTransporter();
credentials: Credentials;
credentials: Credentials = {};

/**
* Provides an alternative Axios request implementation with auth credentials
Expand Down
6 changes: 3 additions & 3 deletions src/auth/googleauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ interface CredentialResult {
}

export class GoogleAuth {
transporter: Transporter;
transporter?: Transporter;

/**
* Caches a value indicating whether the auth layer is running on Google
Expand All @@ -75,8 +75,8 @@ export class GoogleAuth {
return this.checkIsGCE;
}

private _getDefaultProjectIdPromise: Promise<string|null>;
private _cachedProjectId: string|null;
private _getDefaultProjectIdPromise?: Promise<string|null>;
private _cachedProjectId?: string|null;

// To save the contents of the JSON credential file
jsonContent: JWTInput|null = null;
Expand Down
8 changes: 4 additions & 4 deletions src/auth/jwtclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ export class JWT extends OAuth2Client {
scopes?: string|string[];
scope?: string;
subject?: string;
gtoken: GoogleToken;
gtoken?: GoogleToken;
additionalClaims?: {};

private access: JWTAccess;
private access?: JWTAccess;

/**
* JWT service account credentials.
Expand Down Expand Up @@ -157,8 +157,8 @@ export class JWT extends OAuth2Client {
}
this.credentials = result.tokens;
this.credentials.refresh_token = 'jwt-placeholder';
this.key = this.gtoken.key;
this.email = this.gtoken.iss;
this.key = this.gtoken!.key;
this.email = this.gtoken!.iss;
return result.tokens;
}

Expand Down
3 changes: 1 addition & 2 deletions src/auth/oauth2client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export class OAuth2Client extends AuthClient {
// TODO: refactor tests to make this private
_clientSecret?: string;

apiKey: string;
apiKey?: string;

projectId?: string;

Expand Down Expand Up @@ -284,7 +284,6 @@ export class OAuth2Client extends AuthClient {
this.redirectUri = opts.redirectUri;
this.authBaseUrl = opts.authBaseUrl;
this.tokenUrl = opts.tokenUrl;
this.credentials = {};
this.eagerRefreshThresholdMillis =
opts.eagerRefreshThresholdMillis || 5 * 60 * 1000;
}
Expand Down
10 changes: 5 additions & 5 deletions test/test.jwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ describe('JWT auth client', () => {
jwt.authorize((err, creds) => {
assert.equal(err, null);
assert.notEqual(creds, null);
assert.equal('foo@serviceaccount.com', jwt.gtoken.iss);
assert.equal(PEM_PATH, jwt.gtoken.keyFile);
assert.equal(['http://bar', 'http://foo'].join(' '), jwt.gtoken.scope);
assert.equal('bar@subjectaccount.com', jwt.gtoken.sub);
assert.equal('foo@serviceaccount.com', jwt.gtoken!.iss);
assert.equal(PEM_PATH, jwt.gtoken!.keyFile);
assert.equal(['http://bar', 'http://foo'].join(' '), jwt.gtoken!.scope);
assert.equal('bar@subjectaccount.com', jwt.gtoken!.sub);
assert.equal('initial-access-token', jwt.credentials.access_token);
assert.equal(creds!.access_token, jwt.credentials.access_token);
assert.equal(creds!.refresh_token, jwt.credentials.refresh_token);
Expand All @@ -93,7 +93,7 @@ describe('JWT auth client', () => {

createGTokenMock({access_token: 'initial-access-token'});
jwt.authorize((err, creds) => {
assert.equal('http://foo', jwt.gtoken.scope);
assert.equal('http://foo', jwt.gtoken!.scope);
done();
});
});
Expand Down