Class TypeScriptCompilerOptions.Builder
- java.lang.Object
-
- io.github.cdklabs.projen.javascript.TypeScriptCompilerOptions.Builder
-
- All Implemented Interfaces:
software.amazon.jsii.Builder<TypeScriptCompilerOptions>
- Enclosing interface:
- TypeScriptCompilerOptions
@Stability(Experimental) public static final class TypeScriptCompilerOptions.Builder extends Object implements software.amazon.jsii.Builder<TypeScriptCompilerOptions>
A builder forTypeScriptCompilerOptions
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
-
-
-
Method Detail
-
allowArbitraryExtensions
@Stability(Experimental) public TypeScriptCompilerOptions.Builder allowArbitraryExtensions(Boolean allowArbitraryExtensions)
Sets the value ofTypeScriptCompilerOptions.getAllowArbitraryExtensions()- Parameters:
allowArbitraryExtensions- Suppress arbitrary extension import errors with the assumption that a bundler will be handling it.- Returns:
this
-
allowImportingTsExtensions
@Stability(Experimental) public TypeScriptCompilerOptions.Builder allowImportingTsExtensions(Boolean allowImportingTsExtensions)
Sets the value ofTypeScriptCompilerOptions.getAllowImportingTsExtensions()- Parameters:
allowImportingTsExtensions- Allows TypeScript files to import each other with TypeScript-specific extensions (.ts,.mts,.tsx). RequiresnoEmitoremitDeclarationOnly.- Returns:
this
-
allowJs
@Stability(Experimental) public TypeScriptCompilerOptions.Builder allowJs(Boolean allowJs)
Sets the value ofTypeScriptCompilerOptions.getAllowJs()- Parameters:
allowJs- Allow JavaScript files to be compiled.- Returns:
this
-
allowSyntheticDefaultImports
@Stability(Experimental) public TypeScriptCompilerOptions.Builder allowSyntheticDefaultImports(Boolean allowSyntheticDefaultImports)
Sets the value ofTypeScriptCompilerOptions.getAllowSyntheticDefaultImports()- Parameters:
allowSyntheticDefaultImports- Allow default imports from modules with no default export. This does not affect code emit, just typechecking.- Returns:
this
-
allowUnreachableCode
@Stability(Experimental) public TypeScriptCompilerOptions.Builder allowUnreachableCode(Boolean allowUnreachableCode)
Sets the value ofTypeScriptCompilerOptions.getAllowUnreachableCode()- Parameters:
allowUnreachableCode- Allow Unreachable Code. When:undefined(default) provide suggestions as warnings to editorstrueunreachable code is ignoredfalseraises compiler errors about unreachable code
These warnings are only about code which is provably unreachable due to the use of JavaScript syntax.
- Returns:
this
-
allowUnusedLabels
@Stability(Experimental) public TypeScriptCompilerOptions.Builder allowUnusedLabels(Boolean allowUnusedLabels)
Sets the value ofTypeScriptCompilerOptions.getAllowUnusedLabels()- Parameters:
allowUnusedLabels- Allow Unused Labels. When:undefined(default) provide suggestions as warnings to editorstrueunused labels are ignoredfalseraises compiler errors about unused labels
Labels are very rare in JavaScript and typically indicate an attempt to write an object literal:
function verifyAge(age: number) { // Forgot 'return' statement if (age > 18) { verified: true; // ^^^^^^^^ Unused label. } }- Returns:
this
-
alwaysStrict
@Stability(Experimental) public TypeScriptCompilerOptions.Builder alwaysStrict(Boolean alwaysStrict)
Sets the value ofTypeScriptCompilerOptions.getAlwaysStrict()- Parameters:
alwaysStrict- Ensures that your files are parsed in the ECMAScript strict mode, and emit “use strict” for each source file.- Returns:
this
-
baseUrl
@Stability(Experimental) public TypeScriptCompilerOptions.Builder baseUrl(String baseUrl)
Sets the value ofTypeScriptCompilerOptions.getBaseUrl()- Parameters:
baseUrl- Lets you set a base directory to resolve non-absolute module names. You can define a root folder where you can do absolute file resolution.- Returns:
this
-
checkJs
@Stability(Experimental) public TypeScriptCompilerOptions.Builder checkJs(Boolean checkJs)
Sets the value ofTypeScriptCompilerOptions.getCheckJs()- Parameters:
checkJs- Check JS. Works in tandem with allowJs. When checkJs is enabled then errors are reported in JavaScript files. This is the equivalent of including //- Returns:
this
-
customConditions
@Stability(Experimental) public TypeScriptCompilerOptions.Builder customConditions(List<String> customConditions)
Sets the value ofTypeScriptCompilerOptions.getCustomConditions()- Parameters:
customConditions- List of additional conditions that should succeed when TypeScript resolves from anexportsorimportsfield of apackage.json.- Returns:
this
-
declaration
@Stability(Experimental) public TypeScriptCompilerOptions.Builder declaration(Boolean declaration)
Sets the value ofTypeScriptCompilerOptions.getDeclaration()- Parameters:
declaration- To be specified along with the above.- Returns:
this
-
declarationDir
@Stability(Experimental) public TypeScriptCompilerOptions.Builder declarationDir(String declarationDir)
Sets the value ofTypeScriptCompilerOptions.getDeclarationDir()- Parameters:
declarationDir- Offers a way to configure the root directory for where declaration files are emitted.- Returns:
this
-
declarationMap
@Stability(Experimental) public TypeScriptCompilerOptions.Builder declarationMap(Boolean declarationMap)
Sets the value ofTypeScriptCompilerOptions.getDeclarationMap()- Parameters:
declarationMap- Generates a source map for .d.ts files which map back to the original .ts source file. This will allow editors such as VS Code to go to the original .ts file when using features like Go to Definition.- Returns:
this
-
downlevelIteration
@Stability(Experimental) public TypeScriptCompilerOptions.Builder downlevelIteration(Boolean downlevelIteration)
Sets the value ofTypeScriptCompilerOptions.getDownlevelIteration()- Parameters:
downlevelIteration- Downleveling is TypeScript’s term for transpiling to an older version of JavaScript. This flag is to enable support for a more accurate implementation of how modern JavaScript iterates through new concepts in older JavaScript runtimes.ECMAScript 6 added several new iteration primitives: the for / of loop (for (el of arr)), Array spread ([a, ...b]), argument spread (fn(...args)), and Symbol.iterator. downlevelIteration allows for these iteration primitives to be used more accurately in ES5 environments if a Symbol.iterator implementation is present.
- Returns:
this
-
emitDeclarationOnly
@Stability(Experimental) public TypeScriptCompilerOptions.Builder emitDeclarationOnly(Boolean emitDeclarationOnly)
Sets the value ofTypeScriptCompilerOptions.getEmitDeclarationOnly()- Parameters:
emitDeclarationOnly- Only emit .d.ts files; do not emit .js files.- Returns:
this
-
emitDecoratorMetadata
@Stability(Experimental) public TypeScriptCompilerOptions.Builder emitDecoratorMetadata(Boolean emitDecoratorMetadata)
Sets the value ofTypeScriptCompilerOptions.getEmitDecoratorMetadata()- Parameters:
emitDecoratorMetadata- Enables experimental support for decorators, which is in stage 2 of the TC39 standardization process. Decorators are a language feature which hasn’t yet been fully ratified into the JavaScript specification. This means that the implementation version in TypeScript may differ from the implementation in JavaScript when it it decided by TC39. You can find out more about decorator support in TypeScript in the handbook.- Returns:
this
-
esModuleInterop
@Stability(Experimental) public TypeScriptCompilerOptions.Builder esModuleInterop(Boolean esModuleInterop)
Sets the value ofTypeScriptCompilerOptions.getEsModuleInterop()- Parameters:
esModuleInterop- Emit __importStar and __importDefault helpers for runtime babel ecosystem compatibility and enable --allowSyntheticDefaultImports for typesystem compatibility.- Returns:
this
-
exactOptionalPropertyTypes
@Stability(Experimental) public TypeScriptCompilerOptions.Builder exactOptionalPropertyTypes(Boolean exactOptionalPropertyTypes)
Sets the value ofTypeScriptCompilerOptions.getExactOptionalPropertyTypes()- Parameters:
exactOptionalPropertyTypes- Specifies that optional property types should be interpreted exactly as written, meaning that| undefinedis not added to the type Available with TypeScript 4.4 and newer.- Returns:
this
-
experimentalDecorators
@Stability(Experimental) public TypeScriptCompilerOptions.Builder experimentalDecorators(Boolean experimentalDecorators)
Sets the value ofTypeScriptCompilerOptions.getExperimentalDecorators()- Parameters:
experimentalDecorators- Enables experimental support for decorators, which is in stage 2 of the TC39 standardization process.- Returns:
this
-
forceConsistentCasingInFileNames
@Stability(Experimental) public TypeScriptCompilerOptions.Builder forceConsistentCasingInFileNames(Boolean forceConsistentCasingInFileNames)
Sets the value ofTypeScriptCompilerOptions.getForceConsistentCasingInFileNames()- Parameters:
forceConsistentCasingInFileNames- Disallow inconsistently-cased references to the same file.- Returns:
this
-
importsNotUsedAsValues
@Stability(Experimental) public TypeScriptCompilerOptions.Builder importsNotUsedAsValues(TypeScriptImportsNotUsedAsValues importsNotUsedAsValues)
Sets the value ofTypeScriptCompilerOptions.getImportsNotUsedAsValues()- Parameters:
importsNotUsedAsValues- This flag works because you can useimport typeto explicitly create animportstatement which should never be emitted into JavaScript.- Returns:
this
-
incremental
@Stability(Experimental) public TypeScriptCompilerOptions.Builder incremental(Boolean incremental)
Sets the value ofTypeScriptCompilerOptions.getIncremental()- Parameters:
incremental- Tells TypeScript to save information about the project graph from the last compilation to files stored on disk. This creates a series of .tsbuildinfo files in the same folder as your compilation output. They are not used by your JavaScript at runtime and can be safely deleted. You can read more about the flag in the 3.4 release notes.- Returns:
this
-
inlineSourceMap
@Stability(Experimental) public TypeScriptCompilerOptions.Builder inlineSourceMap(Boolean inlineSourceMap)
Sets the value ofTypeScriptCompilerOptions.getInlineSourceMap()- Parameters:
inlineSourceMap- When set, instead of writing out a .js.map file to provide source maps, TypeScript will embed the source map content in the .js files.- Returns:
this
-
inlineSources
@Stability(Experimental) public TypeScriptCompilerOptions.Builder inlineSources(Boolean inlineSources)
Sets the value ofTypeScriptCompilerOptions.getInlineSources()- Parameters:
inlineSources- When set, TypeScript will include the original content of the .ts file as an embedded string in the source map. This is often useful in the same cases as inlineSourceMap.- Returns:
this
-
isolatedModules
@Stability(Experimental) public TypeScriptCompilerOptions.Builder isolatedModules(Boolean isolatedModules)
Sets the value ofTypeScriptCompilerOptions.getIsolatedModules()- Parameters:
isolatedModules- Perform additional checks to ensure that separate compilation (such as with transpileModule or.- Returns:
this
-
jsx
@Stability(Experimental) public TypeScriptCompilerOptions.Builder jsx(TypeScriptJsxMode jsx)
Sets the value ofTypeScriptCompilerOptions.getJsx()- Parameters:
jsx- Support JSX in .tsx files: "react", "preserve", "react-native" etc.- Returns:
this
-
jsxImportSource
@Stability(Experimental) public TypeScriptCompilerOptions.Builder jsxImportSource(String jsxImportSource)
Sets the value ofTypeScriptCompilerOptions.getJsxImportSource()- Parameters:
jsxImportSource- Declares the module specifier to be used for importing the jsx and jsxs factory functions when using jsx.- Returns:
this
-
lib
@Stability(Experimental) public TypeScriptCompilerOptions.Builder lib(List<String> lib)
Sets the value ofTypeScriptCompilerOptions.getLib()- Parameters:
lib- Reference for type definitions / libraries to use (eg. ES2016, ES5, ES2018).- Returns:
this
-
module
@Stability(Experimental) public TypeScriptCompilerOptions.Builder module(String module)
Sets the value ofTypeScriptCompilerOptions.getModule()- Parameters:
module- Sets the module system for the program. See https://www.typescriptlang.org/docs/handbook/modules.html#ambient-modules.- Returns:
this
-
moduleResolution
@Stability(Experimental) public TypeScriptCompilerOptions.Builder moduleResolution(TypeScriptModuleResolution moduleResolution)
Sets the value ofTypeScriptCompilerOptions.getModuleResolution()- Parameters:
moduleResolution- Determine how modules get resolved. Either "Node" for Node.js/io.js style resolution, or "Classic".- Returns:
this
-
noEmit
@Stability(Experimental) public TypeScriptCompilerOptions.Builder noEmit(Boolean noEmit)
Sets the value ofTypeScriptCompilerOptions.getNoEmit()- Parameters:
noEmit- Do not emit outputs.- Returns:
this
-
noEmitOnError
@Stability(Experimental) public TypeScriptCompilerOptions.Builder noEmitOnError(Boolean noEmitOnError)
Sets the value ofTypeScriptCompilerOptions.getNoEmitOnError()- Parameters:
noEmitOnError- Do not emit compiler output files like JavaScript source code, source-maps or declarations if any errors were reported.- Returns:
this
-
noFallthroughCasesInSwitch
@Stability(Experimental) public TypeScriptCompilerOptions.Builder noFallthroughCasesInSwitch(Boolean noFallthroughCasesInSwitch)
Sets the value ofTypeScriptCompilerOptions.getNoFallthroughCasesInSwitch()- Parameters:
noFallthroughCasesInSwitch- Report errors for fallthrough cases in switch statements. Ensures that any non-empty case inside a switch statement includes either break or return. This means you won’t accidentally ship a case fallthrough bug.- Returns:
this
-
noImplicitAny
@Stability(Experimental) public TypeScriptCompilerOptions.Builder noImplicitAny(Boolean noImplicitAny)
Sets the value ofTypeScriptCompilerOptions.getNoImplicitAny()- Parameters:
noImplicitAny- In some cases where no type annotations are present, TypeScript will fall back to a type of any for a variable when it cannot infer the type.- Returns:
this
-
noImplicitOverride
@Stability(Experimental) public TypeScriptCompilerOptions.Builder noImplicitOverride(Boolean noImplicitOverride)
Sets the value ofTypeScriptCompilerOptions.getNoImplicitOverride()- Parameters:
noImplicitOverride- UsingnoImplicitOverride, you can ensure that sub-classes never go out of sync as they are required to explicitly declare that they are overriding a member using theoverridekeyword. This also improves readability of the programmer's intent.Available with TypeScript 4.3 and newer.
- Returns:
this
-
noImplicitReturns
@Stability(Experimental) public TypeScriptCompilerOptions.Builder noImplicitReturns(Boolean noImplicitReturns)
Sets the value ofTypeScriptCompilerOptions.getNoImplicitReturns()- Parameters:
noImplicitReturns- When enabled, TypeScript will check all code paths in a function to ensure they return a value.- Returns:
this
-
noImplicitThis
@Stability(Experimental) public TypeScriptCompilerOptions.Builder noImplicitThis(Boolean noImplicitThis)
Sets the value ofTypeScriptCompilerOptions.getNoImplicitThis()- Parameters:
noImplicitThis- Raise error on ‘this’ expressions with an implied ‘any’ type.- Returns:
this
-
noPropertyAccessFromIndexSignature
@Stability(Experimental) public TypeScriptCompilerOptions.Builder noPropertyAccessFromIndexSignature(Boolean noPropertyAccessFromIndexSignature)
Sets the value ofTypeScriptCompilerOptions.getNoPropertyAccessFromIndexSignature()- Parameters:
noPropertyAccessFromIndexSignature- Raise error on use of the dot syntax to access fields which are not defined.- Returns:
this
-
noUncheckedIndexedAccess
@Stability(Experimental) public TypeScriptCompilerOptions.Builder noUncheckedIndexedAccess(Boolean noUncheckedIndexedAccess)
Sets the value ofTypeScriptCompilerOptions.getNoUncheckedIndexedAccess()- Parameters:
noUncheckedIndexedAccess- Raise error when accessing indexes on objects with unknown keys defined in index signatures.- Returns:
this
-
noUnusedLocals
@Stability(Experimental) public TypeScriptCompilerOptions.Builder noUnusedLocals(Boolean noUnusedLocals)
Sets the value ofTypeScriptCompilerOptions.getNoUnusedLocals()- Parameters:
noUnusedLocals- Report errors on unused local variables.- Returns:
this
-
noUnusedParameters
@Stability(Experimental) public TypeScriptCompilerOptions.Builder noUnusedParameters(Boolean noUnusedParameters)
Sets the value ofTypeScriptCompilerOptions.getNoUnusedParameters()- Parameters:
noUnusedParameters- Report errors on unused parameters in functions.- Returns:
this
-
outDir
@Stability(Experimental) public TypeScriptCompilerOptions.Builder outDir(String outDir)
Sets the value ofTypeScriptCompilerOptions.getOutDir()- Parameters:
outDir- Output directory for the compiled files.- Returns:
this
-
paths
@Stability(Experimental) public TypeScriptCompilerOptions.Builder paths(Map<String,? extends List<String>> paths)
Sets the value ofTypeScriptCompilerOptions.getPaths()- Parameters:
paths- A series of entries which re-map imports to lookup locations relative to the baseUrl, there is a larger coverage of paths in the handbook. paths lets you declare how TypeScript should resolve an import in your require/imports.- Returns:
this
-
resolveJsonModule
@Stability(Experimental) public TypeScriptCompilerOptions.Builder resolveJsonModule(Boolean resolveJsonModule)
Sets the value ofTypeScriptCompilerOptions.getResolveJsonModule()- Parameters:
resolveJsonModule- Allows importing modules with a ‘.json’ extension, which is a common practice in node projects. This includes generating a type for the import based on the static JSON shape.- Returns:
this
-
resolvePackageJsonExports
@Stability(Experimental) public TypeScriptCompilerOptions.Builder resolvePackageJsonExports(Boolean resolvePackageJsonExports)
Sets the value ofTypeScriptCompilerOptions.getResolvePackageJsonExports()- Parameters:
resolvePackageJsonExports- Forces TypeScript to consult theexportsfield ofpackage.jsonfiles if it ever reads from a package innode_modules.- Returns:
this
-
resolvePackageJsonImports
@Stability(Experimental) public TypeScriptCompilerOptions.Builder resolvePackageJsonImports(Boolean resolvePackageJsonImports)
Sets the value ofTypeScriptCompilerOptions.getResolvePackageJsonImports()- Parameters:
resolvePackageJsonImports- Forces TypeScript to consult theimportsfield ofpackage.jsonwhen performing a lookup that begins with#from a file that has apackage.jsonas an ancestor.- Returns:
this
-
rootDir
@Stability(Experimental) public TypeScriptCompilerOptions.Builder rootDir(String rootDir)
Sets the value ofTypeScriptCompilerOptions.getRootDir()- Parameters:
rootDir- Specifies the root directory of input files. Only use to control the output directory structure withoutDir.- Returns:
this
-
skipLibCheck
@Stability(Experimental) public TypeScriptCompilerOptions.Builder skipLibCheck(Boolean skipLibCheck)
Sets the value ofTypeScriptCompilerOptions.getSkipLibCheck()- Parameters:
skipLibCheck- Skip type checking of all declaration files (*.d.ts).- Returns:
this
-
sourceMap
@Stability(Experimental) public TypeScriptCompilerOptions.Builder sourceMap(Boolean sourceMap)
Sets the value ofTypeScriptCompilerOptions.getSourceMap()- Parameters:
sourceMap- Enables the generation of sourcemap files.- Returns:
this
-
sourceRoot
@Stability(Experimental) public TypeScriptCompilerOptions.Builder sourceRoot(String sourceRoot)
Sets the value ofTypeScriptCompilerOptions.getSourceRoot()- Parameters:
sourceRoot- Specify the location where a debugger should locate TypeScript files instead of relative source locations.- Returns:
this
-
strict
@Stability(Experimental) public TypeScriptCompilerOptions.Builder strict(Boolean strict)
Sets the value ofTypeScriptCompilerOptions.getStrict()- Parameters:
strict- The strict flag enables a wide range of type checking behavior that results in stronger guarantees of program correctness. Turning this on is equivalent to enabling all of the strict mode family options, which are outlined below. You can then turn off individual strict mode family checks as needed.- Returns:
this
-
strictNullChecks
@Stability(Experimental) public TypeScriptCompilerOptions.Builder strictNullChecks(Boolean strictNullChecks)
Sets the value ofTypeScriptCompilerOptions.getStrictNullChecks()- Parameters:
strictNullChecks- When strictNullChecks is false, null and undefined are effectively ignored by the language. This can lead to unexpected errors at runtime. When strictNullChecks is true, null and undefined have their own distinct types and you’ll get a type error if you try to use them where a concrete value is expected.- Returns:
this
-
strictPropertyInitialization
@Stability(Experimental) public TypeScriptCompilerOptions.Builder strictPropertyInitialization(Boolean strictPropertyInitialization)
Sets the value ofTypeScriptCompilerOptions.getStrictPropertyInitialization()- Parameters:
strictPropertyInitialization- When set to true, TypeScript will raise an error when a class property was declared but not set in the constructor.- Returns:
this
-
stripInternal
@Stability(Experimental) public TypeScriptCompilerOptions.Builder stripInternal(Boolean stripInternal)
Sets the value ofTypeScriptCompilerOptions.getStripInternal()- Parameters:
stripInternal- Do not emit declarations for code that has an@internalannotation in it’s JSDoc comment.- Returns:
this
-
target
@Stability(Experimental) public TypeScriptCompilerOptions.Builder target(String target)
Sets the value ofTypeScriptCompilerOptions.getTarget()- Parameters:
target- Modern browsers support all ES6 features, so ES6 is a good choice. You might choose to set a lower target if your code is deployed to older environments, or a higher target if your code is guaranteed to run in newer environments.- Returns:
this
-
tsBuildInfoFile
@Stability(Experimental) public TypeScriptCompilerOptions.Builder tsBuildInfoFile(String tsBuildInfoFile)
Sets the value ofTypeScriptCompilerOptions.getTsBuildInfoFile()- Parameters:
tsBuildInfoFile- This setting lets you specify a file for storing incremental compilation information as a part of composite projects which enables faster building of larger TypeScript codebases. You can read more about composite projects in the handbook.- Returns:
this
-
types
@Stability(Experimental) public TypeScriptCompilerOptions.Builder types(List<String> types)
Sets the value ofTypeScriptCompilerOptions.getTypes()- Parameters:
types- If types is specified, only packages listed will be included in the global scope.- Returns:
this
-
useUnknownInCatchVariables
@Stability(Experimental) public TypeScriptCompilerOptions.Builder useUnknownInCatchVariables(Boolean useUnknownInCatchVariables)
Sets the value ofTypeScriptCompilerOptions.getUseUnknownInCatchVariables()- Parameters:
useUnknownInCatchVariables- Change the type of the variable in a catch clause from any to unknown Available with TypeScript 4.4 and newer.- Returns:
this
-
verbatimModuleSyntax
@Stability(Experimental) public TypeScriptCompilerOptions.Builder verbatimModuleSyntax(Boolean verbatimModuleSyntax)
Sets the value ofTypeScriptCompilerOptions.getVerbatimModuleSyntax()- Parameters:
verbatimModuleSyntax- Simplifies TypeScript's handling of import/exporttypemodifiers.- Returns:
this
-
build
@Stability(Experimental) public TypeScriptCompilerOptions build()
Builds the configured instance.- Specified by:
buildin interfacesoftware.amazon.jsii.Builder<TypeScriptCompilerOptions>- Returns:
- a new instance of
TypeScriptCompilerOptions - Throws:
NullPointerException- if any required attribute was not provided
-
-