Skip to content

Commit

Permalink
tsconfig.json should be strict (#549)
Browse files Browse the repository at this point in the history
  • Loading branch information
dphuang2 authored Feb 8, 2024
1 parent c77dd5e commit 93935f0
Show file tree
Hide file tree
Showing 43 changed files with 69 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ default ClientOptInput generateClientOptInput(GenerateBody body, File tmpDir, St
configurator.setRemoveOperationIdPrefix(body.getConfig().getRemoveOperationIdPrefix());
AdditionalProperties addnProp = body.getConfig().getAdditionalProperties();
configurator.setAdditionalProperties(transformAdditionalPropertiesToMap(
body.getConfig().getAdditionalProperties(), body.getConfig().getPackageName(), body.getConfig().getGeneratorName()));
body.getConfig().getAdditionalProperties(), body.getConfig().getPackageName(),
body.getConfig().getGeneratorName(), body.getConfig().getGitUserId()));

// Create folder for output
File outputDir = outputDir(tmpDir, dirName);
Expand Down Expand Up @@ -249,7 +250,7 @@ default ClientOptInput generateClientOptInput(GenerateBody body, File tmpDir, St
* Constructs a map of additional properties to be passed to the generator.
*/
default Map<String, Object> transformAdditionalPropertiesToMap(AdditionalProperties additionalProperties,
String packageName, String generator) {
String packageName, String generator, String gitUserId) {
Map<String, Object> map = new HashMap<>();

// iterate over all properties of AdditionalProperites using reflection and put them in the map
Expand All @@ -272,6 +273,11 @@ default Map<String, Object> transformAdditionalPropertiesToMap(AdditionalPropert
}
});

if ("humanloop".equals(gitUserId)) {
putIfPresent(map, "tsConfigStrict", false);
} else {
putIfPresent(map, "tsConfigStrict", true);
}
if (generator.equals("ruby"))
putIfPresent(map, "isFaraday", true);
if (generator.equals("typescript-axios"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export const setOAuthToObject = async function (object: any, name: string, scope
// check that the token is still valid
const decodedToken = jwtDecode(previousToken);
const currentTime = Date.now() / 1000;
if (decodedToken.exp < currentTime) {
if (decodedToken.exp !== undefined && decodedToken.exp < currentTime) {
await authenticate();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export class {{clientName}}Error extends Error {
super(axiosError.message);
this.name = "{{clientName}}Error";
this.code = axiosError.code;
this.method = axiosError.config.method?.toUpperCase();
this.url = axiosError.config.url;
this.method = axiosError.config?.method?.toUpperCase();
this.url = axiosError.config?.url;
this.status = axiosError.response?.status;
this.statusText = axiosError.response?.statusText;
this.responseBody = responseBody;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"declaration": true,
"target": "ES2015",
"module": "commonjs",
"noImplicitAny": true,
"strict": {{tsConfigStrict}},
"outDir": "dist",
"rootDir": ".",
{{#supportsES6}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export class LeapError extends Error {
super(axiosError.message);
this.name = "LeapError";
this.code = axiosError.code;
this.method = axiosError.config.method?.toUpperCase();
this.url = axiosError.config.url;
this.method = axiosError.config?.method?.toUpperCase();
this.url = axiosError.config?.url;
this.status = axiosError.response?.status;
this.statusText = axiosError.response?.statusText;
this.responseBody = responseBody;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"declaration": true,
"target": "ES2015",
"module": "commonjs",
"noImplicitAny": true,
"strict": true,
"outDir": "dist",
"rootDir": ".",
"lib": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export class LeapError extends Error {
super(axiosError.message);
this.name = "LeapError";
this.code = axiosError.code;
this.method = axiosError.config.method?.toUpperCase();
this.url = axiosError.config.url;
this.method = axiosError.config?.method?.toUpperCase();
this.url = axiosError.config?.url;
this.status = axiosError.response?.status;
this.statusText = axiosError.response?.statusText;
this.responseBody = responseBody;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"declaration": true,
"target": "ES2015",
"module": "commonjs",
"noImplicitAny": true,
"strict": true,
"outDir": "dist",
"rootDir": ".",
"lib": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export const setOAuthToObject = async function (object: any, name: string, scope
// check that the token is still valid
const decodedToken = jwtDecode(previousToken);
const currentTime = Date.now() / 1000;
if (decodedToken.exp < currentTime) {
if (decodedToken.exp !== undefined && decodedToken.exp < currentTime) {
await authenticate();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export class TypescriptSplititError extends Error {
super(axiosError.message);
this.name = "TypescriptSplititError";
this.code = axiosError.code;
this.method = axiosError.config.method?.toUpperCase();
this.url = axiosError.config.url;
this.method = axiosError.config?.method?.toUpperCase();
this.url = axiosError.config?.url;
this.status = axiosError.response?.status;
this.statusText = axiosError.response?.statusText;
this.responseBody = responseBody;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"declaration": true,
"target": "ES2015",
"module": "commonjs",
"noImplicitAny": true,
"strict": true,
"outDir": "dist",
"rootDir": ".",
"lib": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export const setOAuthToObject = async function (object: any, name: string, scope
// check that the token is still valid
const decodedToken = jwtDecode(previousToken);
const currentTime = Date.now() / 1000;
if (decodedToken.exp < currentTime) {
if (decodedToken.exp !== undefined && decodedToken.exp < currentTime) {
await authenticate();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export class TypescriptSplititError extends Error {
super(axiosError.message);
this.name = "TypescriptSplititError";
this.code = axiosError.code;
this.method = axiosError.config.method?.toUpperCase();
this.url = axiosError.config.url;
this.method = axiosError.config?.method?.toUpperCase();
this.url = axiosError.config?.url;
this.status = axiosError.response?.status;
this.statusText = axiosError.response?.statusText;
this.responseBody = responseBody;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"declaration": true,
"target": "ES2015",
"module": "commonjs",
"noImplicitAny": true,
"strict": true,
"outDir": "dist",
"rootDir": ".",
"lib": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export class TypescriptArrayQueryStringClientError extends Error {
super(axiosError.message);
this.name = "TypescriptArrayQueryStringClientError";
this.code = axiosError.code;
this.method = axiosError.config.method?.toUpperCase();
this.url = axiosError.config.url;
this.method = axiosError.config?.method?.toUpperCase();
this.url = axiosError.config?.url;
this.status = axiosError.response?.status;
this.statusText = axiosError.response?.statusText;
this.responseBody = responseBody;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"declaration": true,
"target": "ES2015",
"module": "commonjs",
"noImplicitAny": true,
"strict": true,
"outDir": "dist",
"rootDir": ".",
"lib": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# konfig
#

|Language|Version|Package Manager|README|Source|
|-|-|-|-|-|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export class BellhopError extends Error {
super(axiosError.message);
this.name = "BellhopError";
this.code = axiosError.code;
this.method = axiosError.config.method?.toUpperCase();
this.url = axiosError.config.url;
this.method = axiosError.config?.method?.toUpperCase();
this.url = axiosError.config?.url;
this.status = axiosError.response?.status;
this.statusText = axiosError.response?.statusText;
this.responseBody = responseBody;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"declaration": true,
"target": "ES2015",
"module": "commonjs",
"noImplicitAny": true,
"strict": true,
"outDir": "dist",
"rootDir": ".",
"lib": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export class TypescriptFileUploadNodeClientError extends Error {
super(axiosError.message);
this.name = "TypescriptFileUploadNodeClientError";
this.code = axiosError.code;
this.method = axiosError.config.method?.toUpperCase();
this.url = axiosError.config.url;
this.method = axiosError.config?.method?.toUpperCase();
this.url = axiosError.config?.url;
this.status = axiosError.response?.status;
this.statusText = axiosError.response?.statusText;
this.responseBody = responseBody;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"declaration": true,
"target": "ES2015",
"module": "commonjs",
"noImplicitAny": true,
"strict": true,
"outDir": "dist",
"rootDir": ".",
"lib": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ export class HumanloopError extends Error {
super(axiosError.message);
this.name = "HumanloopError";
this.code = axiosError.code;
this.method = axiosError.config.method?.toUpperCase();
this.url = axiosError.config.url;
this.method = axiosError.config?.method?.toUpperCase();
this.url = axiosError.config?.url;
this.status = axiosError.response?.status;
this.statusText = axiosError.response?.statusText;
this.responseBody = responseBody;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"declaration": true,
"target": "ES2015",
"module": "commonjs",
"noImplicitAny": true,
"strict": false,
"outDir": "dist",
"rootDir": ".",
"lib": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ export class HumanloopError extends Error {
super(axiosError.message);
this.name = "HumanloopError";
this.code = axiosError.code;
this.method = axiosError.config.method?.toUpperCase();
this.url = axiosError.config.url;
this.method = axiosError.config?.method?.toUpperCase();
this.url = axiosError.config?.url;
this.status = axiosError.response?.status;
this.statusText = axiosError.response?.statusText;
this.responseBody = responseBody;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"declaration": true,
"target": "ES2015",
"module": "commonjs",
"noImplicitAny": true,
"strict": false,
"outDir": "dist",
"rootDir": ".",
"lib": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export class TypescriptMultipartFormDataArrayRequestClientError extends Error {
super(axiosError.message);
this.name = "TypescriptMultipartFormDataArrayRequestClientError";
this.code = axiosError.code;
this.method = axiosError.config.method?.toUpperCase();
this.url = axiosError.config.url;
this.method = axiosError.config?.method?.toUpperCase();
this.url = axiosError.config?.url;
this.status = axiosError.response?.status;
this.statusText = axiosError.response?.statusText;
this.responseBody = responseBody;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"declaration": true,
"target": "ES2015",
"module": "commonjs",
"noImplicitAny": true,
"strict": true,
"outDir": "dist",
"rootDir": ".",
"lib": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export class TypescriptMultipartFormDataFreeFormObjectClientError extends Error
super(axiosError.message);
this.name = "TypescriptMultipartFormDataFreeFormObjectClientError";
this.code = axiosError.code;
this.method = axiosError.config.method?.toUpperCase();
this.url = axiosError.config.url;
this.method = axiosError.config?.method?.toUpperCase();
this.url = axiosError.config?.url;
this.status = axiosError.response?.status;
this.statusText = axiosError.response?.statusText;
this.responseBody = responseBody;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"declaration": true,
"target": "ES2015",
"module": "commonjs",
"noImplicitAny": true,
"strict": true,
"outDir": "dist",
"rootDir": ".",
"lib": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export class NewscatcherError extends Error {
super(axiosError.message);
this.name = "NewscatcherError";
this.code = axiosError.code;
this.method = axiosError.config.method?.toUpperCase();
this.url = axiosError.config.url;
this.method = axiosError.config?.method?.toUpperCase();
this.url = axiosError.config?.url;
this.status = axiosError.response?.status;
this.statusText = axiosError.response?.statusText;
this.responseBody = responseBody;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"declaration": true,
"target": "ES2015",
"module": "commonjs",
"noImplicitAny": true,
"strict": true,
"outDir": "dist",
"rootDir": ".",
"lib": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export class NewscatcherError extends Error {
super(axiosError.message);
this.name = "NewscatcherError";
this.code = axiosError.code;
this.method = axiosError.config.method?.toUpperCase();
this.url = axiosError.config.url;
this.method = axiosError.config?.method?.toUpperCase();
this.url = axiosError.config?.url;
this.status = axiosError.response?.status;
this.statusText = axiosError.response?.statusText;
this.responseBody = responseBody;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"declaration": true,
"target": "ES2015",
"module": "commonjs",
"noImplicitAny": true,
"strict": true,
"outDir": "dist",
"rootDir": ".",
"lib": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export class TypescriptNoRelativeNpmLinkClientError extends Error {
super(axiosError.message);
this.name = "TypescriptNoRelativeNpmLinkClientError";
this.code = axiosError.code;
this.method = axiosError.config.method?.toUpperCase();
this.url = axiosError.config.url;
this.method = axiosError.config?.method?.toUpperCase();
this.url = axiosError.config?.url;
this.status = axiosError.response?.status;
this.statusText = axiosError.response?.statusText;
this.responseBody = responseBody;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"declaration": true,
"target": "ES2015",
"module": "commonjs",
"noImplicitAny": true,
"strict": true,
"outDir": "dist",
"rootDir": ".",
"lib": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export class TypescriptOptionalApiKeyError extends Error {
super(axiosError.message);
this.name = "TypescriptOptionalApiKeyError";
this.code = axiosError.code;
this.method = axiosError.config.method?.toUpperCase();
this.url = axiosError.config.url;
this.method = axiosError.config?.method?.toUpperCase();
this.url = axiosError.config?.url;
this.status = axiosError.response?.status;
this.statusText = axiosError.response?.statusText;
this.responseBody = responseBody;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"declaration": true,
"target": "ES2015",
"module": "commonjs",
"noImplicitAny": true,
"strict": true,
"outDir": "dist",
"rootDir": ".",
"lib": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export class TypescriptRelativeNpmLinksClientError extends Error {
super(axiosError.message);
this.name = "TypescriptRelativeNpmLinksClientError";
this.code = axiosError.code;
this.method = axiosError.config.method?.toUpperCase();
this.url = axiosError.config.url;
this.method = axiosError.config?.method?.toUpperCase();
this.url = axiosError.config?.url;
this.status = axiosError.response?.status;
this.statusText = axiosError.response?.statusText;
this.responseBody = responseBody;
Expand Down
Loading

0 comments on commit 93935f0

Please sign in to comment.