-
Notifications
You must be signed in to change notification settings - Fork 10
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
POC of adding full Typescript support #159
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,8 @@ const { | |
pageTsConfigFilePath, | ||
masterPageTsConfigFilePath, | ||
backendTsConfigFilePath, | ||
publicTsConfigFilePath | ||
publicTsConfigFilePath, | ||
ROOT_PATHS | ||
} = require("./sitePaths"); | ||
|
||
let corvidTypes, | ||
|
@@ -18,13 +19,21 @@ let corvidTypes, | |
try { | ||
corvidTypes = require("corvid-types"); | ||
|
||
const SHARED_COMPILER_OPTIONS = { | ||
composite: true, | ||
noEmit: false, | ||
skipLibCheck: true | ||
}; | ||
|
||
pageTsConfigContent = prettyStringify({ | ||
extends: corvidTypes.configPaths.page, | ||
compilerOptions: { | ||
baseUrl: ".", | ||
paths: { | ||
"public/*": ["../../public/*"] | ||
} | ||
"public/*": ["../../public/*"], | ||
"backend/*": ["../../backend/*"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @agankarin |
||
}, | ||
...SHARED_COMPILER_OPTIONS | ||
} | ||
}); | ||
backendTsConfigContent = prettyStringify({ | ||
|
@@ -33,7 +42,8 @@ try { | |
baseUrl: ".", | ||
paths: { | ||
"backend/*": ["./*"] | ||
} | ||
}, | ||
...SHARED_COMPILER_OPTIONS | ||
} | ||
}); | ||
publicTsConfigContent = prettyStringify({ | ||
|
@@ -42,7 +52,8 @@ try { | |
baseUrl: ".", | ||
paths: { | ||
"public/*": ["./*"] | ||
} | ||
}, | ||
...SHARED_COMPILER_OPTIONS | ||
} | ||
}); | ||
} catch (e) { | ||
|
@@ -52,15 +63,45 @@ const isCorvidTypesInstalled = !!corvidTypes; | |
|
||
const getPagesTsConfigs = pages => { | ||
if (!isCorvidTypesInstalled) return []; | ||
return map_(pages, page => ({ | ||
const pagesConfigsToWrite = map_(pages, page => ({ | ||
path: pageTsConfigFilePath(page), | ||
content: pageTsConfigContent | ||
})); | ||
|
||
const rootPagesConfig = { | ||
path: `${ROOT_PATHS.PAGES}/tsconfig.json`, | ||
content: prettyStringify({ | ||
files: [], | ||
references: pagesConfigsToWrite.map(({ path }) => ({ | ||
path: `../${path}` | ||
})) | ||
}) | ||
}; | ||
|
||
return pagesConfigsToWrite.concat(rootPagesConfig); | ||
}; | ||
|
||
const getCodeFilesTsConfigs = () => { | ||
if (!isCorvidTypesInstalled) return []; | ||
const rootTsConfig = { | ||
path: `tsconfig.json`, | ||
content: prettyStringify({ | ||
files: [], | ||
references: [ | ||
{ | ||
path: ROOT_PATHS.PAGES | ||
}, | ||
{ | ||
path: ROOT_PATHS.PUBLIC | ||
}, | ||
{ | ||
path: ROOT_PATHS.BACKEND | ||
} | ||
] | ||
}) | ||
}; | ||
return [ | ||
rootTsConfig, | ||
{ | ||
path: masterPageTsConfigFilePath(), | ||
content: pageTsConfigContent | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@agankarin
Any particularly reason we currently have
noEmit: true
in the base configs incorvid-types
?I think if the user does not have any TS files then this flag will have no effect anyways.