Function isCompilerOptionEnabled

  • Checks if a given compiler option is enabled. It handles dependencies of options, e.g. declaration is implicitly enabled by composite or strictNullChecks is enabled by strict. However, it does not check dependencies that are already checked and reported as errors, e.g. checkJs without allowJs. This function only handles boolean flags.

    Parameters

    • options: CompilerOptions
    • option: "allowImportingTsExtensions" | "allowJs" | "allowArbitraryExtensions" | "allowSyntheticDefaultImports" | "allowUmdGlobalAccess" | "allowUnreachableCode" | "allowUnusedLabels" | "alwaysStrict" | "checkJs" | "declaration" | "declarationMap" | "emitDeclarationOnly" | "disableSizeLimit" | "disableSourceOfProjectReferenceRedirect" | "disableSolutionSearching" | "disableReferencedProjectLoad" | "downlevelIteration" | "emitBOM" | "emitDecoratorMetadata" | "exactOptionalPropertyTypes" | "experimentalDecorators" | "forceConsistentCasingInFileNames" | "importHelpers" | "inlineSourceMap" | "inlineSources" | "isolatedModules" | "keyofStringsOnly" | "noEmit" | "noEmitHelpers" | "noEmitOnError" | "noErrorTruncation" | "noFallthroughCasesInSwitch" | "noImplicitAny" | "noImplicitReturns" | "noImplicitThis" | "noStrictGenericChecks" | "noUnusedLocals" | "noUnusedParameters" | "noImplicitUseStrict" | "noPropertyAccessFromIndexSignature" | "assumeChangesOnlyAffectDirectDependencies" | "noLib" | "noResolve" | "noUncheckedIndexedAccess" | "preserveConstEnums" | "noImplicitOverride" | "preserveSymlinks" | "preserveValueImports" | "composite" | "incremental" | "removeComments" | "resolvePackageJsonExports" | "resolvePackageJsonImports" | "skipLibCheck" | "skipDefaultLibCheck" | "sourceMap" | "strict" | "strictFunctionTypes" | "strictBindCallApply" | "strictNullChecks" | "strictPropertyInitialization" | "stripInternal" | "suppressExcessPropertyErrors" | "suppressImplicitAnyIndexErrors" | "traceResolution" | "useUnknownInCatchVariables" | "resolveJsonModule" | "verbatimModuleSyntax" | "esModuleInterop" | "useDefineForClassFields"

    Returns boolean

    Example

    const options = {
    allowJs: true,
    };

    isCompilerOptionEnabled(options, "allowJs"); // true
    isCompilerOptionEnabled(options, "allowSyntheticDefaultImports"); // false